os components

27
Operating Systems Components

Upload: sammy17

Post on 19-Jan-2015

499 views

Category:

Documents


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: OS COMPONENTS

Operating Systems

Components

Page 2: OS COMPONENTS

2

Operating 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.

Page 3: OS COMPONENTS

3

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

– 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.

Page 4: OS COMPONENTS

4

Types 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.

Page 5: OS COMPONENTS

5

Types 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

Page 6: OS COMPONENTS

6

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:– Text-based also called command-line interfaces.– Graphical

Page 7: OS COMPONENTS

7

Command-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.

Page 8: OS COMPONENTS

8

Advantages 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.

Page 9: OS COMPONENTS

9

The Windows XP Command-Line Interface

Page 10: OS COMPONENTS

10

Windows 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.

Page 11: OS COMPONENTS

11

Examples 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.

Page 12: OS COMPONENTS

12

Example of a Windows Batch file

REM This batch file will append a .BAK extension REM to all .TXT files in the current directoryREM Commands will not be echoed@ECHO OFFREM %1 is a positional parameter, REM in this case it refers to the first character afterREM the batch file nameREM Example of an IF-statementIF %1==N ECHO Skipping

Page 13: OS COMPONENTS

13

Windows Batch File continued

REM Example of a GOTOGOTO L%1REM This is a label:LYDIR /B *.TXTREM Example of a FOR-loopFOR %%F IN (*.TXT) DO REN %%F %%F.BAKDIR /B *.BAK:LNECHO All Done

Page 14: OS COMPONENTS

14

Windows 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 <filename>).

Scripts can be written in VBScript (.VBS) or JavaScript (.JS).

Built into Microsoft Windows 98, 2000, and XP.

Page 15: OS COMPONENTS

15

A Simple WSH Script

REM The Famous HELLO WORLD Program

WSCRIPT.ECHO “Hello World”

Page 16: OS COMPONENTS

16

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

Page 17: OS COMPONENTS

17

WSH Script Example continued

REM This is an example of a functionREM This function will output a stringREM zero-filled to the left up to a specified lengthFUNCTION 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 IFEND FUNCTION

Page 18: OS COMPONENTS

18

WSH Script Example continued

REM Create a file system object which allows manipulationREM of files and foldersset fs = WSCRIPT.CREATEOBJECT("Scripting.FileSystemObject")REM Build the sub-directory nametoday = CSTR(YEAR(DATE())) & zero_pad(MONTH(DATE()),2) _

& zero_pad(DAY(DATE()),2)REM Create the sub-folder if it does not already existIF NOT fs.FOLDEREXISTS(today) then fs.CREATEFOLDER(today)REM Copy files to the sub-folderREM over-write if they already existfs.COPYFILE "*.txt.*", today & "\", TRUE

Page 19: OS COMPONENTS

19

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

– 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.

Page 20: OS COMPONENTS

20

Examples 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

Page 21: OS COMPONENTS

21

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 new9for d in 1 2 3 4 5 6 7 8 9do# The $d indicates that the value of variable d is substitutedmkdir new$ddone

Page 22: OS COMPONENTS

22

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:– on-screen overlapping windows– pointing device– graphical features, such as buttons, icons, etc.– higher level devices, such as menus, toolbars, etc.

Page 23: OS COMPONENTS

23

Features 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.

Page 24: OS COMPONENTS

24

Some examples of toolbarsMicrosoft

Word

Microsoft Excel

Microsoft Access

Note the use of icons that are

common to all the toolbars

Examples include:

Fast Save, Print, and Print Preview

Help

Page 25: OS COMPONENTS

25

Some examples of drop-down menus

Note that options that are not available are ‘greyed’ or ‘ghosted’

Page 26: OS COMPONENTS

26

Some 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

Page 27: OS COMPONENTS

27

Advantages 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.