Operating System Components
Operating System Components
System Components
Operating System Services
System Calls
System Programs
System Structure
Virtual Machines
System Design and Implementation
System Generation
Operating system components
Common System Components
Process Management
Main Memory Management
File Management
I/O System Management
Secondary Management
Networking
Protection System
Command-Interpreter System
Process Management
◦ command-line interpreter
◦ shell (in UNIX)
◦ Accounting - To keep track of which users use how much and what
kinds of computer resources
◦ Protection and security - The owners of information stored in a
multiuser or networked computer system may want to control use of
that information, concurrent processes should not interfere with each
other
Protection involves ensuring that all access to system resources is
controlled
Security of the system from outsiders requires user authentication,
extends to defending external I/O devices from invalid access attempts
If a system is to be protected and secure, precautions must be
instituted throughout it.
A View of Operating System Services
System Calls
Is a programming interface to the services
provided by the OS
Typically written in a high-level language (C or
C++)
Mostly accessed by programs via a high-level
Application Program Interface (API) rather than
direct system call use
Three most common APIs are Win32 API for Windows,
POSIX API for POSIX-based systems (including virtually all
versions of UNIX, Linux, and Mac OS X), and Java API for the
Java virtual machine (JVM)
System Calls
User programs are not allowed to access
system resources directly. They must ask
the OS to do that for them.
OS provides a set of functions that can
be called by user programs to request for
OS services. These functions are called
“system calls”
System Calls
System calls run in kernel mode.
They can be called by executing a special
instruction (trap or software interrupt) which
causes processor to switch to the kernel mode
and jump to a previously defined location in the
kernel.
When the system call finishes, processor returns
to the user program and runs in user mode.
System call
In computing, a system call is how a program
requests a service from an operating
system's kernel.
This may include hardware related services
(e.g. accessing the hard disk), creating and
executing new processes, and
communicating with integral kernel services
System calls provide the interface between a
process and the operating system.
System calls are used whenever a program
needs to access a restricted resource,
Why use APIs rather than system calls?
◦ System calls differ from platform to platform.
By using a stable API, it is easier to migrate
your software to different platforms.
◦ The API can support multiple versions of the
operating system and detect which version it
needs to use at run time.
Program portability
◦ A program using an API can compile and run
on any system that supports the same API
◦ Actual system calls can often be more
detailed and difficult to work with than the
API available to an application programmer.
API (Application Programming
Interface)
An API is a set of functions provided by an
operating system or other system software.
An application program calls the functions to
request the services.
An API clearly defines how to call functions and
what the results are.
Examples: APIs for file system, graphics user
interface, networking, etc.
Whenever a program invokes a system
call, it is interrupted.
CPU then starts executing in the kernel
mode and a routine corresponding to the
system call is executed.
After the completion of that routine the
control is transferred to the user mode
and the program is restored.
Example of System Calls
◦ System call sequence to copy the contents of
one file to another file
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 (API) invokes
intended system call in OS kernel
API – System Call – OS Relationship
Standard C Library Example
C program invoking printf() library call, which calls
write() system call
System Call Parameter Passing
Three general methods used to pass
parameters to the OS
◦ Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
◦ 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
◦ Parameters placed, or 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
Exact type and amount of information vary according to
OS and call
Parameter Passing via Table
Types of System Calls
Process control
File management
Device management
Information maintenance
Communications
Protection
Process Control
end, abort
load, execute
create process, terminate process
get process attributes, set process
attributes
wait for time
wait event, signal event
allocate and free memory
File management
create file, delete file
open, close
read, write, reposition
get file attributes, set file attributes
Device management
request device, release device
read, write, reposition
get device attributes, set device
attributes
logically attach or detach devices
Information maintenance
get time or date, set time or date
get system data, set system data
get device attributes
set device attributes
Communications
create, delete communication connection
send, receive messages
transfer status information
attach or detach remote devices
Examples of Windows and Unix System Calls