Você está na página 1de 34

Operating-System Structures

System Components Virtual Machines System Programs System Calls Operating System Services

Common System Components

y Process Management y Main Memory Management y Secondary-Storage Management y I/O System Management y File Management y Protection System y Networking y Command-Interpreter System

Process Management
y A process is a program in execution. It is a unit of work

within the system. Program is a passive entity, process is an active entity.

y Process needs resources to accomplish its task such as CPU,

memory, I/O, files etc.

y These recourses are given to process either when it is

created or allocated when it is running.

y The CPU executes instructions of a program one after

another, until the process completed.

Process Management(count.)
y The operating system is responsible for the

following activities in connection with process management. y Creating and deleting both user and system processes y process suspension and resumption. y Provision of mechanisms for: y process synchronization y process communication y deadlock handling

Main-Memory Management
y Memory is a large array of words or bytes, each with its own

address. It is a shared by the CPU and I/O devices. y Main memory is a volatile storage device. y CPU reads data from main memory during instruction fetch cycle. I/O operations implemented via DMA. y The operating system is responsible for the following activities in connections with memory management:
y Keep track of which parts of memory are currently being used and by

whom. y Decide which processes to load when memory space becomes available. y Allocate and deallocate memory space as needed.

Secondary-Storage Management
y Since main memory (primary storage) is volatile and too small

to accommodate all data and programs permanently, the computer system must provide secondary storage to back up main memory. y Most modern computer systems use disks as the principle on-line storage medium, for both programs and data. y The operating system is responsible for the following activities in connection with disk management:
y Free space management y Storage allocation y Disk scheduling

I/O System Management

y A computer has many devices that facilitate user interaction

with computer.
y Different devices has different working method. For this

derivers of specific device are loaded into computer. When needed these drivers are loaded in to main memory.
y The operating system is responsible for the following

activities in connection with I/O System Management:

y A general device-driver interface y Drivers for specific hardware devices

File Management
y A computer can store information on different types of media. y For user convenient, OS provides a logical view of information

storage. y A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. y The operating system is responsible for the following activities in connections with file management:
y y y y y

File creation and deletion. Directory creation and deletion. Support of primitives for manipulating files and directories. Mapping files onto secondary storage. File backup on stable (nonvolatile) storage media.

Protection System
y The processes of a computer must be protected to from one another

activities. OS ensure that Files, Memory, CPU, and other resource are used by only authorized processes.
y Protection refers to a mechanism for controlling access by

programs, processes, or users to both system and user resources.

y The operating system is responsible for the following activities in

connections with protection management::

y distinguish between authorized and unauthorized usage. y specify the controls to be imposed. y provide a means of enforcement.

Networking (Distributed Systems)

y A distributed system is a collection processors that do not

share memory or a clock. Each processor has its own local memory. y The processors in the system are connected through a communication network. y A distributed system provides user access to various system resources. y Access to a shared resource allows:
y Computation speed-up y Increased data availability y Enhanced reliability

Command-Interpreter System
y One of the most important system program for an OS is the

command interpreter. It is the interface between user and OS. y Many commands are given to OS by Control statements. When a new job OS started in Batch system or a user log on in a time sharing system, a program executes automatically. This program reads and interprets control statements. This program is called Control Card Interpreter or Command Line interpreter.

Command-Interpreter System(count.)
y Many commands are given to the operating system by

control statements which deal with:

y process creation and management y I/O handling y secondary-storage management y main-memory management y file-system access y protection y networking

Operating System Services

y An OS provides an environment for program execution and

provides some facilities for program and user. Different OS provides different services. Some common services are given below

1. Program execution The main purpose of OS is to provide an efficient and convenient environment for program execution. So an OS provides various functions for loading a program into main memory and execute it. Every running program must terminate either normally or abnormally. 2. I/O operations A running program may need I/O operation (for reading data or to give output). This I/O may be from /to a file. This I/O may be from /to a I/O device. All these operations are managed by an OS.

Operating System Services(count.)

1. File-system manipulation OS provides capability to read, write, create, and delete files. 2. Communications Os manages Inter Process Communication (IPC). It may be needed to exchange of information between processes executing either on the same computer or on different systems (on a network). OS provides IPC for this purpose. 3. Error detection OS ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs. OS provides mechanism for error detection and removal of error.

Additional Operating System Functions

Additional functions exist not for helping the user, but rather for ensuring efficient system operations.

Resource allocation allocating resources to multiple users or

multiple jobs running at the same time.

Accounting keep track of and record which users use how

much and what kinds of computer resources. It helps in making future decisions for resource allocation

Protection ensuring that all access to system resources is


System Calls
y System calls provide the interface between a running y y y

program and the operating system. Generally available as assembly-language instructions. Several languages (such as C,C++) can be used to write system calls. To understand System call, let a program reads a data from a file and copy it to another file. The first input that the program will need is the name of two files. Once the names are specified , the program must open both files and then copy the required data. All these are done with the help of System Calls. System call can be divided into 5 categories-------

1. Process control 2. File Management 3. Device Management 4. Information maintenance 5. communication

System calls for Process control

1. End , Abort 2. Load , Execute 3. Create process, terminate process 4. Get process attribute , set process attribute 5. Wait for time 6. Wait event, signal event 7. Allocate and free memory

Process control
y A running program must stop either normally (end) or

abnormally(Abort). On abnormal stop OS must provide appropriate message. y Load and executes system calls are used to bring a program into main memory and its execution. y If we Create a process than its execution is controlled by its attributes( priority, cpu time , etc). These attributes are gained by Get process attribute and set
process attribute system calls. To terminate a process terminate system calls is used. y Wait system calls is used when a process waits for an event(user input, busy resource etc.)

System calls for File Management

1. Create and delete file 2. Open , close 3. Read, write , reposition 4. Get file attribute , set file attribute

System calls for Device Management

1. Request device , release device

Read, write , reposition 3. Get device attribute , set device attribute 4. Logically attach or detach device.(distributed system)

Device Management
y A process may need additional resource for its

execution. These additional resources may be more memory, tape drive, access to file etc. y Many system calls are needed for devices. y If there are many user then user must first Request the device and after use user must Release it. After allotment user can read, write the device.

System calls for Information maintenance

1. Get time or date, set time or date

Get system date, set system date 3. Get process , file or device attribute 4. Set process , file or device attribute

System calls for communication

1. Create ,delete communication connection 2. Send , receive message 3. Transfer status information 4. Attach or detach remote devices.

y There are 2 common methods for communication ,

MESSAGE PASSING and SHARED MEMORY. y In message passing IPC is used. Before communication starts a path must be established.
y Each computer in a network has a host name and each

process has an ID. To know the name of another host and process get hostid and get processid system calls are used.

y The other communicator respond by accept connection

system call. Both communicator communicates with the help of read message and write message system calls. y The close connection system call terminates the coomunication.

y In shared memory method processes us map memory system


System Programs
y System programs provide a convenient environment

for program development and execution. The can be divided into:

y File manipulation y Status information y File modification y Programming language support y Program loading and execution y Communications y Application programs

File manipulation
y OS provides programs for--1. Create file 2. Delete file 3. Rename file 4. Copy file 5. Print file 6. List file 7. Manipulating files

Status information
y OS provides programs for---

Date 2. Time 3. Available memory 4. Number of currently logged on user


File modification
y OS provides programs for--y Text editors to create and modify files y Special commands to search contents of files or perform

transformations of the text

Programming language support

y OS provides programs for--y Compilers, y assemblers, y debuggers y Interpreters

Program loading and execution

y OS provides programs for--y Absolute loaders y relocatable loaders y linkage editors y Debugging

y OS provides programs for---

Virtual connection b/w processes & users 2. Sending messages