Vous êtes sur la page 1sur 28

OPERATING SYSTEMS OVERVIEW

Definition:
 An Operating system is software that manages the computer hardware.
 It acts as an intermediatery between user and computer hardware.
 It provides an environment in which a user can execute programs in a
convenient and efficient manner.
 It is a monitoring program.
 It is a resource allocator.

The abstract view of components of a computer

1. Hardware: Provides basic computing resources for the system. Like CPU, Memory, I/O
Devices.
2. System and Application Programs: Defines the ways in which the resources are used to
solve user’s computing problem.

3. Operating Systems: Provides an environment Controls the hardware and coordinates


its use among the various application programs for various users. Like a government.
4. Users: Uses the resources of a computer system.
Operating System Services
The services provided by the operating system differ from one to another operating system.

The services those are helpful to users

1. User Interface: Allows interacting with system. The various user interfaces are
a. Command Line Interface: Uses text commands and a method for entering them.
Uses Command prompt. eg: shell (UNIX), DOS.
b. Batch Interface: All the commands and directives are entered into files and the
file is executed.eg: shell script in UNIX/LINUX
c. Graphical User Interface: The interface is a window system with a pointing
device to direct I/O, choose from menus, and make selections and a keyboard to
enter text. Eg: Windows, Apple Mac OS X, UNIX and Linux have CLI with
optional GUI interfaces.
2. Program Execution:
a. The system must be able to load program into memory and to run that
program.
b. The program must end its execution either normally or abnormally (Indicating
error).
3. I/O Operations: A running program may require I/O, for efficiency and protection;
users usually cannot control I/O devices directly. Hence Operating system has to
perform I/O.
4. File System Manipulation: For files
a. Files can be created, deleted, searched by name
b. File permissions to allow or deny access to file or directory based on ownership.
c. Programs need to read and write files and directories.
d. Organizing file system structure
All these services must be provided by Operating System.
5. Communications:
a. One process needs to exchange information with another process.
b. Process communication occurs between two processes that are executing on
same computer or different computers in a network.
c. Operating system provides process communication by using pipes, shared
memory and message passing.
6. Error Detection: Operating system needs to be constantly aware of possible errors and
it has to take appropriate action to ensure correct and consistent computing. The
errors may occur in
a. CPU , Memory (Power failure, Timer error , Memory Insufficient)
b. I/O Devices (Parity errors, Printer Errors, Connection failure in network).
c. User Program (Arithmetic Overflow , Illegal memory access , use of more CPU
time)

The services those are helpful to for efficient operation of the system can be

1. Resource Allocation: Operating system has to manage different types of resources.


When multiple users or multiple jobs running at the same time, the OS has to allocate
the resources.
The recourses can be
a. CPU clock cycles (CPU Time)
b. Main Memory
c. File Storage (Disks)
d. I/O Devices

2. Accounting: The operating system has to record and keep track of which users how
much and what kind of resources.
This information is for
a) Accounting (Billing)
b) Using statistics the researchers can reconfigure system to improve
computing services.

3. Protection & Security:


a. When several process executing concurrently they should not interfere with
others or with the operating system. Protection involves ensuring that all access
to the system resources is controlled.
b. In a multi user and networked systems, the file and I/O system access must be
secured from unauthorized access. Security must ensure from external attacks.
System Calls

 System calls provide an interface to the services made available by an operating


system.
 Programming interface to the services provided by the OS
 System calls are generally available as routines written in C and C++, although certain
low-level tasks (for example, tasks where hardware must be accessed directly) may
need to be written using assembly-language instructions.
 Mostly accessed by programs via a high-level Application Programming Interface (API)

Three most common APIs are

1. Win32 API for Windows


2. POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux,
and Mac OS X)
3. Java API for the Java virtual machine (JVM)

Example to writing a simple program to read data from one files and copy them to another
file.

The system call sequence to copy the contents of one file to another
To write, accept, open, create, abort, read, close and terminate on file operations require
system calls provided by the operating system in the form of API.

The run-time support system (a set of functions built into libraries included with a compiler)
for most programming languages provides a system-call interface that serves as the link to
system calls made available by the operating system.

System calls Implementation:

Example Handling of User application invoking open () system call.

API – System Call – OS Relationship

The system call implementation is

1. The system call interface takes the function and invokes the necessary system call
within the operating system.
2. A number is associated with each system call; the interface maintains a table indexed
according to these numbers.
3. After invoking the system call, returns the status of system call and any return values.

The callers need not to know anything about how the system call is implemented. Just needs
to obey API and understand what OS will do as a result call.

System calls occur in different ways depending on the computer in use.


Each system call will send additional information to the operating system in the form of
parameters.

Three general methods used to pass parameters to the OS

1. Pass the parameters in registers.


 In some cases, may be more parameters than registers
2. Parameters stored in a block, or table, in memory, and address of block passed as a
parameter in a register.
 This approach taken by Linux and Solaris
3. Parameters pushed onto the stack by the program and popped off the stack by the
operating system.
 Block and stack methods do not limit the number or length of
parameters being passed

Types of System calls:

System calls are grouped into 6 major categories.


1. Process control
create process, terminate process
end, abort
load, execute
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
Locks for managing access to shared data between processes
2. File management
create file, delete file
open, close file
read, write, reposition
get and set file attributes
3. Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
4. Information maintenance
get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
5. Communications
create, delete communication connection
send, receive messages
transfer status information
attach and detach remote devices
6. Protection
Control access to resources
Get and set permissions
Allow and deny user access

System calls in UNIX/Windows


System Programs

 System Programs or System Utilities provide a convenient environment for program


development and execution.
 System programs are user interfaces to system calls and some other are more complex
tasks.
 Most users’ view of the operation system is defined by system programs, not the actual
system calls.

System programs are can be divided into the following categories.

1. File management: These programs create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories.

2. Status information:
 Some ask the system for info - date, time, amount of available memory, disk
space, number of users
 Others provide detailed performance, logging, and debugging information
 Typically, these programs format and print the output to the terminal or other
output devices
 Some systems implement a registry - used to store and retrieve configuration
information
3. File modification:
 Text editors to create and modify files
 Special commands to search contents of files or perform transformations of the
text

4. Programming-language support: Compilers, assemblers, debuggers and interpreters


sometimes provided by operating system for common programming languages like C,
C++, Java, etc.

5. Program loading and execution: Once a Program is compiled or translated, it must be


loaded in to memory. The operating system provides Absolute loaders, relocatable
loaders, linkage editors, debugging systems for higher-level and machine language.

6. Communications: Provide the mechanism for creating virtual connections among


processes, users, and computer systems.
Allow users to send messages to one another’s screens, browse web pages, send
electronic-mail messages, and log in remotely, transfer files from one machine to
another etc.

7. Application Programs: Operating system provides programs like web browsers, word
processors, text formatters, database systems, compilers, games and statistical
packages.
Operating System Operations

Most of the operating systems are Interrupt Driven. An operating system performs any service
with an event. Events are signaled by an interrupt or trap(exception).

The interrupt can be


1. Hardware interrupts : By any one of the device
2. Software Interrupts : interrupt or trap
a. Software error (e.g., division by zero)
b. Request for operating system service
c. Process problems include infinite loop, processes modifying each other or
the operating system

For each type of interrupt, separate segment of code (Interrupt Service Routine-ISR) in the
operating system determine what action is taken.

Since the operating system and users share the hardware and software resources of the
computer, Operating system must ensure that an incorrect program cannot cause other
programs to execute incorrectly.

For this, operating systems uses

1. Dual Mode operation:

To ensure the proper execution of operating systems, we must be able to distinguish


between the execution of operating-system code and user defined code.

Operating System OS Programs / ISRs – Kernel


Area

Main Memory
User Area
User Programs - User

Computer systems provide hardware support that allows us to differentiate among various
modes of execution.

Mostly, the CPU is operated in two modes (Dual Mode).

1. User Mode / Non- Privileged Mode: The computer system is operated on behalf of a
user application .i.e .Executes user program.
2. System/Priviliged/supervisory/Kernel Mode: The computer system executed operating
system programs to obtain the system services.
When a user program requires the service of an operating system, the CPU switch from user to
kernel mode.

A mode bit is added to the hardware of the computer to indicate the current mode.

Mode bit 0 -> Kernel Mode

Mode bit 1 -> User mode

With mode bit we can distinguish between a tasks is executed on behalf of operating system
or user.

The dual mode operation provides, protecting operating system from errant users by keeping
all user services is stored in OS area. So that only privileged instructions can allow to execute
OS program.

The instruction to switch from user mode to kernel mode is a privileged instruction

The user obtains the services of the system by means of system calls. When a system call is
executed it is treated by CPU as Software Interrupt. It causes to switch from user mode to
system mode or vice versa.

The transition from User to Kernel Mode

The Life cycle of execution in a system is

1. Initially Control resides in Operating System, Where instructions are executed in Kernel
Mode.
2. When control is given to the user application based on interrupt, the mode is set to
user mode.
3. Eventually, control is switched back to the operating system via a trap, interrupt or a
system call.

Most of the operating systems Windows, UNIX, LINUX, and Solaris use Dual-Mode operation
to protect the system.
2. Timer:

The operating system must maintain a control over the CPU.


Example: Operating System cannot allow
 A user program to get stuck in infinite loop
 Fail to call system services
 Never return control to the operating system
To avoid this, a timer is used.

 A timer can be set to interrupt the computer after a specified period of time.
 The period may be fixed or variable, set by operating system.
 A privileged instruction can only modify the content of timer.

Before running the control to user, the Operating system ensures that the timer is set
to interrupt. If the timer interrupts, control transfers automatically to operating
system. The Operating system then decides to give more time or treat as a fatal error.

A simple method is to initialize counter with an amount of time that the program is
allowed to run. As long as the counter is positive, the control is with user program.
When the counter becomes negative, Operating system terminates the program.
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner

Vous aimerez peut-être aussi