OS - System Structure

32
Vinay Arora CSED,TU System Structure Organized By: Vinay Arora Assistant Professor CSED, TU

description

 

Transcript of OS - System Structure

Page 1: OS - System Structure

Vinay AroraCSED,TU

System Structure

Organized By: Vinay Arora

Assistant Professor

CSED, TU

Page 2: OS - System Structure

Vinay Arora

CSED,TU

Disclaimer

This is NOT A COPYRIGHT MATERIAL

Content has been taken mainly from the following books:

Operating Systems Concepts By Silberschatz & Galvin, Operating Systems: Internals and Design Principles By William Stallings

www.os-book.com

www.cs.jhu.edu/~yairamir/cs418/os2/sld001.htm

www.personal.kent.edu/~rmuhamma/OpSystems/os.html

http://msdn.microsoft.com/en-us/library/ms685096(VS.85).aspx

http://www.computer.howsttuffworks.com/operating-system6.htm

http://williamstallings.com/OS/Animations.htmlhttp://msdn.microsoft.com/en-us/library/aa450566.aspx

www.os-book.com

http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html

Etc…

Page 3: OS - System Structure

Vinay Arora

CSED,TU

Operating System Services

� User Interface - Almost all operating systems have a user interface.

Command-Line (CLI), Graphics User Interface (GUI)

� Program Execution - The system must be able to load a program into memory and to run that program, end execution.

� I/O Operations - A running program may require I/O, which may involve a file or an I/O device.

� File-System Manipulation - Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.

Page 4: OS - System Structure

Vinay Arora

CSED,TU

Operating System Services

Page 5: OS - System Structure

Vinay Arora

CSED,TU

� Communications – Processes may exchange information.

� Communications may be via shared memory or through message passing.

� Error Detection – OS needs to be constantly aware of possible errors

� May occur in the CPU and memory hardware, in I/O devices or in user program

� For each type of error, OS should take the appropriate action.

� Debugging facilities

Page 6: OS - System Structure

Vinay Arora

CSED,TU

Operating System Interface - CLI

CLI allows direct command entry

� Sometimes implemented in kernel, sometimes by systems

program

� Sometimes multiple flavors implemented – shells

� Primarily fetches a command from user and executes it

� Sometimes commands built-in, sometimes just names of

programs

� If the latter, adding new features doesn’t require shell

modification

Page 7: OS - System Structure

Vinay Arora

CSED,TU

CLI

Page 8: OS - System Structure

Vinay Arora

CSED,TU

CLI

Page 9: OS - System Structure

Vinay Arora

CSED,TU

Operating System Interface - GUI

� User-friendly desktop metaphor interface

� Usually mouse, keyboard, and monitor

� Icons represent files, programs, actions, etc

� Various mouse buttons over objects in the interface cause various

actions (provide information, options, execute function, open

directory (known as a folder)

� Many systems now include both CLI and GUI interfaces

Page 10: OS - System Structure

Vinay Arora

CSED,TU

GUI

Page 11: OS - System Structure

Vinay Arora

CSED,TU

Layered View

Page 12: OS - System Structure

Vinay Arora

CSED,TU

System Call

� Programming interface to the services provided by the OS.

� Typically written in a high-level language (C or C++)

� The invocation of an operating system routine.

� Operating systems contain sets of routines for performing various low-

level operations.

� For example, all operating systems have a routine for creating a

directory. If you want to execute an operating system routine from a

program, you must make a system call.

Page 13: OS - System Structure

Vinay Arora

CSED,TU

� Mostly accessed by programs via a high-level Application Program

Interface (API) rather than direct system call use.

� Why use APIs rather than system calls? – There are specific reasons for

using APIs or Programming with APIs, Instead of direct System Calls.

Page 14: OS - System Structure

Vinay Arora

CSED,TU

System Call Sequence when Copying from One

File to another

Page 15: OS - System Structure

Vinay Arora

CSED,TU

API

� Consider the ReadFile() function in the Win32 API—a function for reading from a file

Description of the parameters passed to ReadFile()

HANDLE file—the file to be read

LPVOID buffer—a buffer where the data will be read into and written from

DWORD bytesToRead—the number of bytes to be read into the buffer

LPDWORD bytesRead—the number of bytes read during the last read

LPOVERLAPPED ovl—indicates if overlapped I/O is being used

Page 16: OS - System Structure

Vinay Arora

CSED,TU

System Call Implementation

� Typically, a number associated with each system call

� System-call interface maintains a table indexed according to these numbers

� The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values

� The caller need know nothing about how the system call is implemented

� Just needs to obey API and understand what OS will do as a result call

� Most details of OS interface hidden from programmer by API

Managed by run-time support library (set of functions built into libraries included with compiler)

Page 17: OS - System Structure

Vinay Arora

CSED,TU

System Call Interface

Page 18: OS - System Structure

Vinay Arora

CSED,TU

Example – Windows/Unix system Call

Page 19: OS - System Structure

Vinay Arora

CSED,TU

Types of System Calls

� Process Control

� File Management

� Device Management

� Information Maintenance

� Communications

Page 20: OS - System Structure

Vinay Arora

CSED,TU

System Program

� Provide a convenient environment for program development and

execution

� Some of them are simply user interfaces to system calls; others are

considerably more complex

Page 21: OS - System Structure

Vinay Arora

CSED,TU

Standard C Library Example

� C program invoking printf() library call, which calls write() system call

Page 22: OS - System Structure

Vinay Arora

CSED,TU

Operating System Design & Implementation

� Important principle to separate

Policy: What will be done?

Mechanism: How to do it?

� Mechanisms determine how to do something, policies decide what will

be done

� The separation of policy from mechanism is a very important

principle, it allows maximum flexibility if policy decisions are to be

changed later

Page 23: OS - System Structure

Vinay Arora

CSED,TU

Layered Approach

� The operating system is divided into a number of layers (levels), each

built on top of lower layers.

� The bottom layer (layer 0), is the hardware; the highest (layer N) is the

user interface.

� With modularity, layers are selected such that each uses functions

(operations) and services of only lower-level layers

Page 24: OS - System Structure

Vinay Arora

CSED,TU

Layered View of Operating System

Page 25: OS - System Structure

Vinay Arora

CSED,TU

Microkernel System Structure

� Moves as much from the kernel into “user” space

� Communication takes place between user modules using message passing

� Benefits:

� Easier to extend a microkernel

� Easier to port the operating system to new architectures

� More reliable (less code is running in kernel mode)

� More secure

� Detriments:

� Performance overhead of user space to kernel space communication

Page 26: OS - System Structure

Vinay Arora

CSED,TU

Virtual Machines

� Fundamental Idea behind a virtual machine is to abstract the hardware

of a single Computer into several different execution environments.

� Illusion will be created that each separate execution environment is

running its own private computer.

� The Operating System creates the illusion of multiple processes, each

executing on its own processor with its own (virtual) memory.

� The virtual-machine concept provides complete protection of system

resources since each virtual machine is isolated from all other virtual

machines.

Page 27: OS - System Structure

Vinay Arora

CSED,TU

VMware Architecture

Page 28: OS - System Structure

Vinay Arora

CSED,TU

BIOS

Page 29: OS - System Structure

Vinay Arora

CSED,TU

Motherboard BIOS

Page 30: OS - System Structure

Vinay Arora

CSED,TU

System Boot

� Operating system must be made available to hardware so hardware can

start it

� Small piece of code – bootstrap loader, locates the kernel, loads it

into memory, and starts it

� Sometimes two-step process where boot block at fixed location

loads bootstrap loader

� When power initialized on system, execution starts at a fixed

memory location

� Firmware used to hold initial boot code

Page 31: OS - System Structure

Vinay Arora

CSED,TU

Booting Steps

� Power On the Computer Machine.

� NO Data to process for the Processor.

� Data present in BIOS ROM will be processed first.

� Perform POST.

� Display System Settings.

� Load Interrupt Handler and Device Drivers.

� Check CMOS for custom settings.

� Initiate the Bootstrap sequence.

� Searching for target BOOT drive.

� Locate the MBR .

� Start OS.

Page 32: OS - System Structure

Vinay Arora

CSED,TU

Thnx…