Operating Systems

Download Report

Transcript Operating Systems

Operating Systems
Components
Operating System Components

An operating system is conceptually broken
into three sets of components:
–
–
–
2
a user interface (which may consist of a graphical
user interface and/or a command line
interpreter or "shell"),
low-level system utilities,
a kernel - which is the heart of the operating
system.
What is a kernel



The central module of an operating system.
A piece of software responsible for providing secure
access to the computer hardware.
A kernel includes
–
–
–
3
an interrupt handler that handles all requests or completed
I/O operations that compete for the kernel's service.
a scheduler that determines which programs share the
kernel's processing time in what order.
a supervisor that actually gives use of the computer to each
process when it is scheduled.
Types of kernels

Monolithic Kernel
–
–
–

Microkernel
–
–
4
includes all (or at least, most) of its services in the kernel
proper.
the amount of code running in kernel space makes the
kernel more prone to fatal bugs.
Linux uses a monolithic kernels that allows loading and
unloading of kernel modules at runtime.
runs most services - like networking, filesystem, etc. - in
user space.
microkernels can be more stable, but require additional
design work.
Types of kernels

Hybrid (Modified Microkernel)
–
–
5
microkernels that have some "non-essential" code
in kernelspace in order for that code to run more
quickly.
Windows NT/2000 and Macintosh OS X use
hybrid kernels
User Interface


The user interface is a program or set of
programs that sits as a layer above the
operating system itself.
Two common types of user interfaces:
–
–
6
Text-based also called command-line interfaces.
Graphical
Command-Line Interface (CLI)



7
Method of interacting with a computer by
giving it lines of textual commands either
from the keyboard or from a script.
In its simplest form the user types a
command after the computer displays a
prompt character.
Programs that implement these interfaces
are called command-line interpreters.
Advantages of CLIs




8
Skilled users may be able to user a command line
faster than a GUI for simple tasks.
All options and operations are invokable in a
consistent form, one "level" away from the basic
command.
All options and operations are controlled in more or
less the same way.
Can perform operations in a batch processing mode
without user interaction.
The Windows XP Command-Line Interface
9
Windows Command Prompt
Commands


Windows uses a program called CMD.EXE to
interpret user commands.
Command Format
–
–
–

Batch files
–
–
–
10
command-name options argument
only the command-name is mandatory
the options component consists of one or more switches
flagged by an initial forward-slash (/) character.
Group of commands in a file that run one after the other.
Uses a very simple control language – IF, FOR, GOTO.
Has a .CMD or .BAT extension.
Examples of Windows Commands






11
HELP – displays list of available commands
DEL FILE1.TXT – deletes a file named FILE1.TXT in the
current folder.
COPY \MYSTUFF\FILE2.DOC FILE3.DOC – copy FILE1.DOC
in the MYSTUFF folder to FILE3.DOC in the current folder
DIR /OD – displays list of files in current folder sorted by date,
oldest first
DIR /X /P – displays list of short names of files in current folder,
pausing after each screenful.
XCOPY /S *.TXT \MYSTUFF – copies all files with the .TXT
extension in the current folder and all sub-folders into the
MYSTUFF folder.
Example of a Windows Batch file
REM This batch file will append a .BAK extension
REM to all .TXT files in the current directory
REM Commands will not be echoed
@ECHO OFF
REM %1 is a positional parameter,
REM in this case it refers to the first character after
REM the batch file name
REM Example of an IF-statement
IF %1==N ECHO Skipping
12
Windows Batch File continued
REM Example of a GOTO
GOTO L%1
REM This is a label
:LY
DIR /B *.TXT
REM Example of a FOR-loop
FOR %%F IN (*.TXT) DO REN %%F %%F.BAK
DIR /B *.BAK
:LN
ECHO All Done
13
Windows Scripting Host (WSH)





14
A Windows administration tool that extends the
scripting functionality beyond batch files.
Creates an environment for hosting scripts.
Scripts can be run from either the Windows desktop
(double-click on the file) or the command prompt
(CSCRIPT <filename>).
Scripts can be written in VBScript (.VBS) or
JavaScript (.JS).
Built into Microsoft Windows 98, 2000, and XP.
A Simple WSH Script
REM The Famous HELLO WORLD Program
WSCRIPT.ECHO “Hello World”
15
A More Complex WSH Script
REM This script will copy all files whose names
REM contain .txt to a sub-directory, the name
REM of the sub-directory will be the current date
REM in YYYYMMDD format
REM Declare some variables
DIM fs, today
16
WSH Script Example continued
REM This is an example of a function
REM This function will output a string
REM zero-filled to the left up to a specified length
FUNCTION zero_pad(p_in, p_length)
IF LEN(CSTR(p_in)) >= p_length THEN
zero_pad = CSTR(p_in)
ELSE
zero_pad = STRING(p_length - LEN(CSTR(p_in)), "0") _
& CSTR(p_in)
END IF
END FUNCTION
17
WSH Script Example continued
REM Create a file system object which allows manipulation
REM of files and folders
set fs = WSCRIPT.CREATEOBJECT("Scripting.FileSystemObject")
REM Build the sub-directory name
today = CSTR(YEAR(DATE())) & zero_pad(MONTH(DATE()),2) _
& zero_pad(DAY(DATE()),2)
REM Create the sub-folder if it does not already exist
IF NOT fs.FOLDEREXISTS(today) then fs.CREATEFOLDER(today)
REM Copy files to the sub-folder
REM over-write if they already exist
fs.COPYFILE "*.txt.*", today & "\", TRUE
18
UNIX Command System




A program called a shell is used to interpret UNIX commands.
UNIX has numerous shells – Bourne Shell, C-Shell, Bourne-Again
shell, etc.
UNIX commands are case-sensitive
Command Format
–
–
–
–

Scripts
–
–
19
command-name options argument #comment
only the command-name is mandatory
the options component consists of one or more switches
each switch consists of a minus-sign followed by one or more characters.
group of commands in a file that run one after the other.
UNIX has a very powerful control language, comparable to other
programming systems.
Examples of UNIX Commands





20
pwd – displays names of current directory.
ls -l /tmp – list files in /tmp in long format.
rm -r * – delete all files in current directory and all
sub-directories
cp /tmp/*sh /home/class – copy all files in the /tmp
directory whose names in sh to the /home/class
directory
mkdir new1 – create a sub-directory called new1 in
the current directory
A Simple Unix Shell Script
#! /bin/sh
# The preceding line indicates that this is a
# Bourne-shell script
# This shell script will create sub-directories
# in the current directory with names new1 to new9
for d in 1 2 3 4 5 6 7 8 9
do
# The $d indicates that the value of variable d is substituted
mkdir new$d
done
21
Graphical User Interface (GUI)



First GUI developed at the Palo ALTO Research
Center of Xerox Corporation.
Apple Macintosh, released in 1984, was the first
commercial use of a GUI.
GUIs have a number of common features:
–
–
–
–
22
on-screen overlapping windows
pointing device
graphical features, such as buttons, icons, etc.
higher level devices, such as menus, toolbars, etc.
Features of a GUI






23
Window – main central area used to display and
interact with user data.
Scroll bar – used to reposition the viewing window.
Title bar – indicates the name of the program
currently being used and its associated document.
Menu bar – list of words which constitute the toplevel choices of a menu.
Pop-up/Drop-down menu – list of choices that
appear when a top-level menu item is clicked.
Toolbar – Group of icons that perform a function
when clicked.
Some examples of toolbars
Microsoft
Word
Microsoft
Excel
Microsoft
Access
Note the use of
icons that are
common to all the
toolbars
24
Examples
include:
Fast Save,
Print, and Print
Preview
Help
Some examples of drop-down menus
25
Note that options that are not available
are ‘greyed’ or ‘ghosted’
Some examples of pop-up menus
The
Microsoft
Windows
‘Start’ Menu
pops up
when the
‘Start’ button
is pressed
26
The ‘AutoShapes’ Menu
in Microsoft Word pops
up when the
‘AutoShapes’ button is
pressed
Advantages of GUIs





27
Performing tasks in a GUI environment is intuitive.
Applications have the same general appearance and
operation.
Applications are flexible, commands can be
executed using either mouse or keyboard.
GUIs allow you to cancel or undo operations.
GUIs often ask you to confirm important operations.