Module 1 Introduction
Module 1 Introduction
MODULE 1
• Some users may use PC’s. Here the system is designed so that
only one user can utilize the resource, as a result performance
will be good.
• OS is a control program
–Controls execution of programs to prevent errors and improper use
of the computer.
• Kernel
-- The program that executes forever.
Computer Startup
• When a computer is powered up ,it needs to have initial program to
run. This initial program is called bootstrap program stored in ROM
or EPROM, generally known as firmware.
• Interrupts are signals sent to the CPU by I/O devices. They tell the
CPU to stop its current activities and execute appropriate part of the
operating system.
Interrupts
•When the CPU is interrupted, it stops what it is doing and immediately
transfers execution to a fixed location.
•The fixed location usually contains the starting address where the
service routine for the process is located.
• Most programs are stored on a disk until they are loaded into
memory. Many programs then use the disk as both the source and
the destination of their processing.
Storage-Device Hierarchy
• The wide variety of storage systems in a computer system can be
organized in a hierarchy according to speed and cost.
Advantages :
1. Increased throughput : By increasing the number of
processors more work will be done in less time. When multiple
process cooperate on task, a certain amount of overhead is
incurred in keeping all parts working correctly.
Multi Processing Systems (Cont.)
2. Economy of scale : Multi processor system can save more
money than multiple processor, since they share peripherals,
mass storage & power supplies.
• Asymmetric multiprocessing
-- Each processor is assigned a specific task; master processor
schedules and allocates work to slave processors.
-- More common in extremely large systems.
Clustered Systems
• Clustered systems gather together multiple CPUs to accomplish
computational work.
Multiprogramming (1 CPU)
-- Process requires CPU time and I/O time.
-- J1 goes to I/O device then CPU can take other jobs & process it.
-- CPU will not be idle and busy all the times as a result efficiency
will be improved .
-- Time Sharin
Multitasking
• All (or part) of the data that is needed by the program must be in
memory. Memory management determines what is in memory .
• File-System management
– Files usually organized into directories
– Access control on most systems to determine who can access
what.
– OS activities include
• Creating and deleting files and directories
• Primitives to manipulate files and directories
• Mapping files onto secondary storage
• Backup files onto stable (non-volatile) storage media
Mass-Storage Management
• Usually disks used to store data that does not fit in main memory
or data that must be kept for a “long” period of time.
• OS activities
– Free-space management
– Storage allocation
– Disk scheduling
Caching
• Caching is an important principle of computer systems.
• Since the various CPUs can all execute concurrently ,we must make
sure that update to the value of A in one cache is immediately
reflected to all other caches.
Multimedia Systems
• Multimedia data consist of video and audio files such as MP3, DVD
movies, video conferencing, and short video clips of movie
previews or news stories downloaded over the internet.
Handheld Systems
• It includes Pocket-Pc’s, cellular telephones which use
special-purpose embedded operating systems.
• Because of their size, most handheld devices have small amounts of
memory, slow processors, and small display screens.
Computing Environments
Traditional Computing
• In a "typical office environment" consisted of PCs connected to a
network, with servers providing file and print services.
• Once a node has joined the network, it can begin providing services
to and requesting services from other nodes in the network.
• 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 of system 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).
API – System Call – OS Relationship
Standard C Library Example
Background Services
– Provide facilities like disk checking, process scheduling, error
logging, printing
– Run in user context not kernel context and also known as
services, subsystems.
Operating System Design and Implementation
• Design and implementation of OS not “solvable”, but some
approaches have proven successful.
E.g. : Application programs are able to access the basic I/O routine to
write directly to the display . As a result when user program fails
entire system crashes.
BIOS(basic I/O system)
Non Simple Structure -- UNIX
UNIX – limited by hardware functionality, the original UNIX
operating system had limited structuring.
The UNIX OS consists of two separable parts - system programs
and kernel.
Kernel :
•Consists of everything below the system-call interface and
above the physical hardware.
•Provides the file system, CPU scheduling, memory
management, and other operating-system functions, a large
number of functions for one level.
Traditional UNIX System Structure
Beyond simple but not fully layered
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.
Each virtual machine has its own virtual CPU, memory, disk drives,
network interfaces, and so forth.
Operating System generation
• The system must then be generated for each specific computer
site, a process sometimes known as SYSGEN.
• SYSGEN program reads from a given file, or asks the operator of
the system for information concerning the specific configuration of
the hardware.
• The following kinds of information must be determined.
What CPU is to be used?
How much memory is available?
How will the boot disk be formatted? How many sections, or
"partitions,“ will it be separated into, and what will go into each
partition?
What operating-system options are desired? how many buffers of
which sizes should be used, what type of CPU-scheduling
algorithm is desired, what the maximum number of processes to
be supported.
CHAPTER 3 PROCESS
Process Concept
• Process – Program in execution; process execution must
progress in sequential fashion.
PCB
Process Scheduling
• Multiprogramming :To have some process running at all times.
• Time Sharing : Switch the CPU among processes so frequently
that users can interact with each program while it is running.
• Process scheduler selects among available processes for next
execution on CPU.
• Scheduling queues: As processes enters the system , they are
put in to job queue.
– Job queue – set of all processes in the system
– Ready queue – set of all processes residing in main memory,
ready and waiting to execute are kept on a list.
– Device queues – set of processes waiting for an I/O device.
– Processes migrate among the various queues
Ready Queue
Each PCB includes a pointer field that points to the next PCB in
the ready queue.
Representation of Process Scheduling
Queuing diagram :
Each rectangular box represents a queue. The circles represent
the resources that serve the queues.
A new process is initially put in the ready queue. Once the process
is allocated the CPU and is executing, one of several events could
occur.
Schedulers
• Short-term scheduler (CPU scheduler) – selects which process
should be executed next and allocates CPU.
– Short-term scheduler is invoked frequently (milliseconds) ⇒
(must be fast)
• Long-term scheduler (job scheduler) – selects which processes
should be brought into the ready queue.
– Long-term scheduler is invoked infrequently (seconds,
minutes) ⇒ (may be slow)
– The long-term scheduler controls the degree of
multiprogramming
• Processes can be described as either:
– I/O-bound process – spends more time doing I/O than
computations, many short CPU bursts.(the amount of time the
process uses the processor before it is no longer ready.)
– CPU-bound process – spends more time doing computations,
few very long CPU bursts.
Addition of Medium Term Scheduling
● Medium-term scheduler can be added if degree of multiple
programming needs to decrease.
● Remove process from memory, store on disk, bring back in
from disk to continue execution: swapping
● It is necessary to improve process mix because change in
memory requirements has overcommitted the available
memory requiring memory to be freed up.
Context Switch
• When CPU switches to another process, the system must save
the state of the old process and load the saved state for the new
process via a context switch.
• Execution options
– Parent and children execute concurrently.
– Parent waits until children terminates.
• System call fork() is used to create
processes. It takes no arguments and
returns a process ID. The purpose of fork()
is to create a new process, which
becomes the child process of the caller.
Process Creation (Cont.)
Address space
• The child process is a duplicate of the parent process (it has the
same program and data as the parent).
• The child process has a new program loaded into it.
• UNIX examples
– fork() system call creates new process.
– exec() system call used after a fork() to replace the process
memory space with a new program.
C Program Forking Separate Process
Process Termination
• Process executes last statement and then asks the operating
system to delete it using the exit() system call.
– Returns status data from child to parent (via wait())
– Process resources are deallocated by operating system.
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
Bounded-Buffer – Producer
item next_produced;
while (true) {
/* produce an item in next produced */
while (((in + 1) % BUFFER_SIZE) == out)
; /* do nothing */
buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
}
Bounded Buffer – Consumer
item next_consumed;
while (true) {
while (in == out)
; /* do nothing */
next_consumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
• Implementation issues:
– How are links established?
– Can a link be associated with more than two processes?
– How many links can there be between every pair of
communicating processes?
– What is the capacity of a link?
– Is the size of a message that the link can accommodate fixed
or variable?
– Is a link unidirectional or bi-directional?
Message Passing (Cont.)
• Operations
– create a new mailbox (port)
– send and receive messages through mailbox
– destroy a mailbox
• Primitives are defined as:
send(A, message) – send a message to mailbox A
receive(A, message) – receive a message from mailbox A
Indirect Communication
• Mailbox sharing
– P1, P2, and P3 share mailbox A
– P1, sends; P2 and P3 receive
– Who gets the message?
• Solutions
– Allow a link to be associated with at most two processes.
– Allow only one process at a time to execute a receive operation.
– Allow the system to select arbitarily the receiver. Sender is
notified who the receiver was.
Synchronization
• Message passing may be either blocking or non-blocking.