Title: Operating Systems
1Operating Systems
2Operating System Components
- An operating system is conceptually broken into
three sets of components - 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.
3What 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
- 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.
4Types of kernels
- Monolithic Kernel
- 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. - Microkernel
- runs most services - like networking, filesystem,
etc. - in user space. - microkernels can be more stable, but require
additional design work.
5Types of kernels
- Hybrid (Modified Microkernel)
- 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
6User 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
- Text-based also called command-line interfaces.
- Graphical
7Command-Line Interface (CLI)
- 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.
8Advantages of CLIs
- 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.
9The Windows XP Command-Line Interface
10Windows Command Prompt Commands
- Windows uses a program called CMD.EXE to
interpret user commands. - Command Format
- 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. - Batch files
- 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.
11Examples of Windows Commands
- 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.
12Example 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
- _at_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 1N ECHO Skipping
13Windows Batch File continued
- REM Example of a GOTO
- GOTO L1
- 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
14Windows Scripting Host (WSH)
- 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 ltfilenamegt). - Scripts can be written in VBScript (.VBS) or
JavaScript (.JS). - Built into Microsoft Windows 98, 2000, and XP.
15A Simple WSH Script
- REM The Famous HELLO WORLD Program
- WSCRIPT.ECHO Hello World
16A 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
17WSH 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)) gt 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
18WSH Script Example continued
- REM Create a file system object which allows
manipulation - REM of files and folders
- set fs WSCRIPT.CREATEOBJECT("Scripting.FileSyste
mObject") - 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
19UNIX 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
- 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. - Scripts
- group of commands in a file that run one after
the other. - UNIX has a very powerful control language,
comparable to other programming systems.
20Examples of UNIX Commands
- 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
21A 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 newd
- done
22Graphical 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
- on-screen overlapping windows
- pointing device
- graphical features, such as buttons, icons, etc.
- higher level devices, such as menus, toolbars,
etc.
23Features of a GUI
- 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
top-level 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.
24Some examples of toolbars
Microsoft Word
Microsoft Excel
Microsoft Access
Note the use of icons that are common to all the
toolbars
Fast Save, Print, and Print Preview
Examples include
Help
25Some examples of drop-down menus
Note that options that are not available are
greyed or ghosted
26Some examples of pop-up menus
The Microsoft Windows Start Menu pops up when
the Start button is pressed
The AutoShapes Menu in Microsoft Word pops up
when the AutoShapes button is pressed
27Advantages of GUIs
- 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.