Unit 2-OS structure

32  Download (0)

Full text

(1)
(2)

OPERATING SYSTEM CONCEPTS

THE MOST IMPORTANT CONCEPTS

RELATED TO OS ARE GIVEN AS UNDER:

PROCESS

FILES

THE SHELL

SYSTEM CALL

(3)

OPERATING SYSTEM CONCEPTS

PROCESS:

PROCESS IS THE PROGRAM IN EXECUTION.

THE ENTITY THAT CAN BE ASSIGNED TO AND EXECUTED ON A

PROCESSOR

IT CONSISTED OF THE EXECUTABLE PROGRAM, THE PROGRAM’S

DATA, AND STACK, PROGRAM COUNTER, STACK POINTER AND OTHER REGISTERS.

• ALL THESE INFORMATION ARE STORED IN THE PROCESS TABLE.

(4)

OPERATING SYSTEM CONCEPTS

FILES:

FILES CONSISTS OF SEQUENCE OF BIT,

BYTE, LINES OR RECORDS WHOSE

MEANINGS ARE DEFINED BY ITS CREATOR.

FILES ARE MAPPED BY THE OS ON TO THE

PHYSICAL DEVICES.

(5)

THE SHELL:

EDITORS, COMPILERS, ASSEMBLERS, LINKERS AND

COMMAND INTERPRETERS ARE NOT THE PART OF OS.

UNIX COMMAND INTERPRETER IS CALLED THE SHELL. • SHELL MAKE HEAVY USE OF MANY OS FEATURES.

• IT IS INTERFACE BETWEEN A USER AND THE OS.

• WHEN ANY USER LOG IN, A SHELL IS STARTED UP.

THE SHELL HAS TERMINAL AS STANDARD INPUT AND

STANDARD OUTPUT.

5

(6)

OS KERNEL

 THE AUI IS GLUED TO THE OS KERNEL VIA THE LANGUAGE LIBRARIES AND THE SYSTEM CALL INTERFACE

 THE LANGUAGE LIBRARIES AND THE SYSTEM CALL INTERFACE COMPRISE APPLICATION PROGRAMMER’S INTERFACE (API)

 THE SYSTEM CALL INTERFACE LAYER CONTAINS ENTRY POINT IN THE KERNEL CODE

 ANY USER OR APPLICATION REQUEST THAT INVOLVES ACCESS TO ANY SYSTEM RESOURCE MUST BE HANDLED BY THE

KERNEL CODE

(7)

OS KERNEL

REAL WORK IS DONE IN THE

KERNEL

7

Users

Applications

(8)

ENTRY POINTS INTO KERNEL

8

System Call

Signal

(9)

OS KERNEL

KERNEL CONSISTS OF EVERYTHING BELOW THE SYSTEM CALL

INTERFACE AND ABOVE THE PHYSICAL H/W.

THE AUI IS GLUED TO THE OS KERNEL VIA THE LANGUAGE

LIBRARIES AND THE SYSTEM CALL INTERFACE

THE LANGUAGE LIBRARIES AND THE SYSTEM CALL INTERFACE

COMPRISE APPLICATION PROGRAMMER’S INTERFACE (API)

THE SYSTEM CALL INTERFACE LAYER CONTAINS ENTRY POINT

IN THE KERNEL CODE

ANY USER OR APPLICATION REQUEST THAT INVOLVES ACCESS

TO ANY SYSTEM RESOURCE MUST BE HANDLED BY THE KERNEL CODE

(10)

OS KERNEL

THE KERNEL CONTAINS THE CODE TO PERFORM THE

FOLLOWING FUNCTIONS:

INTERRUPT HANDLING

PROCESS CREATION AND DESTRUCTION

PROCESS STATE SWITCHING  DISPATCHING

PROCESS SUSPENSION AND RESUMPTION

PROCESS SYNCHRONIZATION

INTER PROCESS COMMUNICATION (IPC)MANIPULATION OF PCB

MEMORY MANAGEMENT

SUPPORT FOR FILE SYSTEM ETC.

(11)

SYSTEM CALLS:

USER PROCESSES MUST NOT BE GIVEN OPEN ACCESS TO THE KERNEL CODE

ANY USER/APPLICATION REQUEST THAT INVOLVES ACCESS TO

ANY SYSTEM RESOURCE MUST BE HANDLED BY THE KERNEL CODE.

SYSTEM CALL IS A MECHANISM USED BY AN APPLICATION

PROGRAM TO REQUEST A SERVICE FROM OPERATING SYSTEM.

SYSTEM CALL IS A LAYER OF S/W AT THE TOP OF KERNEL THAT

ALLOWS YOU TO GO INSIDE THE KERNEL CODE.

A SYSTEM CALL IS USUALLY A REQUEST TO THE OS KERNEL TO

DO A HW, SYSTEM SPECIFIC OR PRIVILEGED OPERATION.

11

(12)

SYSTEM CALLS:

STEP 1: A USER PROGRAM MAKES A CALL TO A LIBRARY FUNCTION.

 CORRESPONDING TO EACH SYSTEM CALL IS A LIBRARY CALL.

STEP 2: LIBRARY ROUTINE PUTS APPROPRIATE PARAMETERS AT A WELL-KNOWN PLACE (REGISTERS, STACK, OR A TABLE IN MEMORY).

STEP 3: THE TRAP INSTRUCTION IS EXECUTED TO CHANGE MODE FROM USER TO KERNEL.

STEP 4: CONTROL GOES TO OPERATING SYSTEM.

12

(13)

SYSTEM CALL

13

Library Call

System Call

trap

Dispatch Table

Process

Service Code Kernel

Code

Dispatch Table

(14)

OS CONCEPTS

SYSTEM CALLS

STEP 5: OS DETERMINES WHICH SYSTEM CALL IS TO BE CARRIED AND EXAMINES THE PARAMETERS.

STEP 6: KERNEL INDEXES THE DISPATCH TABLE, WHICH CONTAINS POINTERS TO SERVICE ROUTINES FOR

SYSTEM CALLS.

STEP 7: SERVICE ROUTINE IS EXECUTED.

IF THE PARAMETERS ARE VALID, OS PERFORMS TASKS AND FINAL RESULT IS SENT BACK TO USER PROCESS. OTHERWISE IT RETURN ERROR AND THAT ERROR REPORT IS ALSO SENT BACK TO PROCESS.

STEP 8: CONTROL IS GIVEN BACK TO THE USER PROGRAM. STEP 9: LIBRARY FUNCTION EXECUTES THE INSTRUCTION

(15)

15

OS Components

Process management

Main memory management

Secondary storage management

I/O system management

File management

Protection system

Networking

(16)

OPERATING SYSTEM STRUCTURES

OS IS A COMPLEX SYSTEM AND MUST BE

STRUCTURED CAREFULLY.

A COMMON APPROACH IS TO PARTITION

THE SYSTEM INTO SMALL COMPONENTS

WITH EACH COMPONENT PERFORMING A

WELL-DEFINED TASK.

FOLLOWING STRUCTURES ARE USED FOR

OS:

 SIMPLE STRUCTURE  LAYERED APPROACH  MICROKERNELS

 MODULES

(17)

SIMPLE STRUCTURES …

MONOLITHIC SYSTEMS:

THE STRUCTURE IS THAT THERE IS NO STRUCTURE.

THE OS IS WRITTEN AS A COLLECTION OF PROCEDURES.

EACH PROCEDURE CAN CALL OTHER PROCEDURE WHENEVER IT NEEDS.

THERE IS NO INFORMATION HIDING; EVERY PROCEDURE IS VISIBLE TO EVERY

OTHER PROCEDURE

IN THIS APPROACH ALL THE INDIVIDUAL PROCEDURES ARE COMPLIED

TOGETHER INTO SINGLE OBJECT FILE WITH THE LINKER.

EVEN IN MONOLITHIC SYSTEMS, HOWEVER, IT IS POSSIBLE TO HAVE AT LEAST A

LITTLE STRUCTURE. THE SYSTEM CALLS PROVIDED BY THE OS ARE REQUESTED BY PUTTING THE PARAMETERS IN WELL-DEFINED PLACES, SUCH AS IN

REGISTERS OR ON THE STACK, AND THEN EXECUTING A SPECIAL TRAP

(18)

SIMPLE STRUCTURES

MS-DOS : WRITTEN TO PROVIDE THE MOST FUNCTIONALITY IN THE LEAST SPACE, SO IT WAS NOT DIVIDED INTO MODULES CAREFULLY

(19)

SIMPLE STRUCTURES …

UNIX

CONSISTS OF TWO SEPARABLE

PARTS, THE KERNEL AND THE SYSTEM

PROGRAMS.

EVERY THING BELOW THE SYSTEM CALL

INTERFACE AND ABOVE THE PHYSICAL

HARDWARE IS THE KERNEL.

AN ENORMOUS AMOUNT OF

FUNCTIONALITY COMBINED IN ONE

LEVEL, UNIX IS DIFFICULT TO ENHANCE

AS CHANGES IN ONE SECTION COULD

(20)

UNIX SYSTEM STRUCTURE

(21)

21

Layered Approach

The OS is broken up into a number of

layers

Bottom layer is hardware and the

topmost layer (layer N) is the user

interface

A typical layer consists of data

structures and a set of routines to

service the layer above it

(22)

22

(23)

23

Layered Approach …

Modularity

Each layer uses functions and services of only

lower layers

Simplifies debugging and system verification.The major difficulty with layered approach is

careful definition of layers, because a layer can only use the layers below it

Less efficient than other approaches;

e.g. when a program executes an I/O operation, it executes a system call that is trapped to the I/O layer, which in turn call the memory mgmt layer, which in turn call the CPU

(24)

24

Microkernel

Structures the operating system by removing all

non-essential components from the kernel and implementing them as system and user level programs

Smaller kernel

Only few essential services / functions are assigned

to the kernel; e.g. address space checking, IPC and basic scheduling. Other OS services (file service, memory service, terminal service, process service) are given to servers that run in user mode and are treated like any other

application by the microkernel

Main function is to provide a communication facility

(25)

25

Microkernel …

Windows NT Client-Server Structure

(26)

26

Microkernel …

Advantages

Easier to extend the OS—new services are added to user space and

consequently do not require modification of the kernel and/or its recompilation

Easier to maintain operating system code (enhancement, debugging, etc.)OS is easier to port from one hardware to another

Fault Isolation. Since all the servers run as user-mode processes, and not in

kernel mode, they do not have direct access to the h/w. As a consequence, if a bug in the File Server is triggered, the file service may crash, but this will not usually bring the whole system down

More security and reliability

Disadvantages

Performance decreases due to extensive message passing (IPC)

(27)

27

Modules

Most modern operating systems implement modules

using object-oriented approach.

The kernel has a set of core components and

dynamically links in additional services.

Each module talks to others over known interfaces.

It resembles layered system; but it is more flexible in

that any module can call any other module.

It is also like microkernel in that primary module has

only core functions but is more efficient because

(28)

28

Virtual Machines

Abstract the hardware of a single computer into

several different execution environments,

thereby creating an illusion that each separate

execution environment is running its own

computer.

On a time-sharing system with virtual machine

(29)

29

Virtual Machines …

In conventional multiprogramming processes are allocated a portion of the real machine resources. The same machine resources are distributed among several processes.

In virtual multiprogramming system, a single real machine gives an illusion of several virtual machines, each having its own virtual processor, storage and I/O devices.

Conventional Multiprogrammed OS

Job 2 . . . . Job n

Virtual Machine OS

VM 1 VM 2 . . . VM n

(30)

30

Virtual Machines …

(31)

31

(32)

32

Virtual Machines

System development done without disrupting

normal system operation. Provides complete

protection of system resources, since VM is

isolated from all other VMs.

A perfect vehicle for OS research and

development.

Figure

Updating...

References

Related subjects : OS/2 Unit 2