Chapter 1: Introduction: (OS Structure, Modes and Services)
Chapter 1: Introduction: (OS Structure, Modes and Services)
2. System View:
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair
resource use
OS is a control program
Controls execution of programs to prevent errors and
improper use of the computer
Who controls the execution of programs to
prevent errors and improper use of
computer?
a) Resource allocator
b) Control Program
c) Hardware
d) None of the above
Operating-System Operations
Modern OS’s are Interrupt driven.
Program or software send generate events by using system calls.
Error or request by a software creates exception or trap
Division by zero, request for operating system service
Batch Systems
Early computers were Physically enormous machines run from a
console
The common input devices were card readers and tape drives.
The common output devices were line printers, tape drives, and
card punches.
The user did not interact directly with the computer systems.
User prepare a job -which consisted of the program, and submitted it
to the computer operator.
after minutes, hours, or days, the output appeared.
To speed up processing, operators batched jobs with similar needs
together and ran them through the computer as a group.
In which type of operating system users do
not interact directly with the computer
system?
a) Multiprogramming operating systems
b) Multiprocessing operating systems
c) Batch operating systems
d) Distributed operating systems
Multiprogrammed OS
Needed for efficiency
Single user cannot keep CPU and I/O devices busy at
all times
Multiprogramming organizes jobs (code and data) so
CPU always has one to execute
A subset of total jobs in system is kept in memory
One job selected and run via job scheduling
When it has to wait (for I/O for example), OS switches
to another job
What is the objective of multiprogramming
operating systems?
a) Maximize CPU utilization
b) Switch the CPU among processes
c) Achieve multitasking
d) None of the above
Timesharing OS
Timesharing (multitasking) is logical extension in
which CPU switches jobs so frequently that users can
interact with each job while it is running, creating
interactive computing
Each user has at least one program executing in
memory process
If several jobs ready to run at the same time CPU
scheduling
If processes don’t fit in memory, swapping moves
them in and out to run
Virtual memory allows execution of processes not
completely in memory
Multitasking Systems
Types of Multitasking:
Time Driven
Task specific
MS-DOS – written to
provide the most
functionality in the least
space
Not divided into modules
Non Simple Structure -- UNIX
UNIX – limited by hardware functionality
The UNIX OS consists of two separable parts:
Systems programs
The kernel
Traditional UNIX System Structure
Beyond simple but not fully layered
Layered Approach
The operating system is divided
into a number of layers (levels)
Each layer is 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, each layer uses
functions (operations) and
services of only lower-level
layers
Architecture of a Linux system −
Hardware layer − Hardware consists of all
peripheral devices (RAM/ HDD/ CPU etc).
Kernel − It is the core component of
Operating System, interacts directly with
hardware, provides low level services to
upper layer components.
Shell − An interface to kernel, hiding
complexity of kernel's functions from
users. The shell takes commands from the
user and executes kernel's functions.
Kernel
Kernel is the core part of Linux. It is
responsible for all major activities of this
operating system.
It consists of various modules and it
interacts directly with the underlying
hardware.
Monolithic Kernels
Main function
OS services
Utility
functions
Microkernel System Structure
Communication takes place between user modules
using message passing
Example of microkernel: Mach
Mac OS X kernel (Darwin) partly based on Mach
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
Disadvantage:
Performance overhead of user space to kernel space
communication
Microkernel System Structure
messages messages
microkernel
hardware
Monolithic Kernels VS Micro kernels
Hybrid Kernels
Combine the best of both worlds
Speed and simple design of a monolithic
kernel
Modularity and stability of a microkernel
Still similar to a monolithic kernel
Disadvantages still apply here
E.g. Windows NT
Operating System Services
An operating system provides an environment for the programs to run.
It provides certain services to programs
Operating System Services
Operating-system services provides functions that are helpful to the
user:
Process control
End, abort, load, execute, create process, terminate process, wait, get
process attributes, set attributes.
File management
Create file, delete file, open, close, read, write, reposition.
Device management
Request device, release device, read, write, logically attach and
detach device.
Information maintenance
Get time, date, set time date, get system data, set system data.
Communications
Create, delete communication connection, send receive messages,
transfer status information.
Process Control Calls
fork() – create a new process
pid = fork();
The fork() function shall create a new process. The new process
(child process) shall be an exact copy of the calling process
(parent process) except some process’ system properties
It returns ‘twice’
return value == 0 ... child
return value > 0 ... parent (returned value is the child’s pid)
exit() – terminate a process
void exit(int status);
The exit() function shall then flush all open files with unwritten
buffered data and close all open files. Finally, the process shall be
terminated and system resources owned by the process shall be
freed
The value of ‘status’ shall be available to a waiting parent process
The exit() function should never return
File Access Calls
open – open file
fd = open(const char *path, int oflag, ...);
The open() function shall establish the connection between a file
and a file descriptor. The file descriptor is used by other I/O
functions to refer to that file. The path argument points to a
pathname naming the file.
The parameter oflag specifies the open mode:
ReadOnly, WriteOnly, ReadWrite
Create, Append, Exclusive, ...