Professional Documents
Culture Documents
What Is An Operating System?: Four Components of Computer System
What Is An Operating System?: Four Components of Computer System
Sunbeam Infotech 2
Sunbeam Infotech 5
Hard disks Hard disk settings
There are two types of hard disks The SATA hard disk can be directly connected to
PATA / IDE motherboard using special SATA cable.
SATA The PATA hard disk can be connected to
SATA drives are faster as compared to PATA drives. motherboard using other type of cable.
These disks are connected to motherboard using PATA drive must be configured using jumper settings
different kind of connectors. in one of the following modes:
Todays motherboards have one (or more) port/s for Primary Master
PATA, while more than four ports for SATA. Primary Slave
These ports can be used to connect hard disks, Secondary Master
CD/DVD R/W or printers. Secondary Slave
Booting process
When computer is started, the instruction pointer
(program counter) is loaded with a predefined memory
location and execution starts there.
The initial boot program is kept here in ROM, as RAM is
in an unknown state at system startup.
The bootstrap program run diagnostics to determine the
state of machine (hardware).
It also initialize CPU registers, device controllers and such
things so that basic system is initialized.
It loads kernel of OS from the disk/device to the memory
and starts the first process of that kernel.
Finally one or more system processes are created which
functions as an operating system.
Sunbeam Infotech 17 Sunbeam Infotech 18
Computer System Structure
Sunbeam Infotech
Sunbeam Infotech 2
Sunbeam Infotech
Sunbeam Infotech 23
Multiprogramming Multitasking
Single user cannot keep CPU and I/O devices Multitasking (Time sharing) is logical extension in
busy at all times which CPU switches jobs so frequently that users can
interact with each job while it is running
Multiprogramming organizes jobs (code and
data) so CPU always has one to execute Response time should be < 1 second
A subset of total jobs in system is kept in If several jobs ready to run at the same time CPU
memory scheduling is necessary to schedule them all.
One job selected and run via job scheduling Multitasking can be achieved in one of the ways:
multi-processing
When any job has to wait (for I/O for example),
OS switches to another job multi-threading
Multiprogramming needed to use the system Virtual memory allows execution of processes not
in efficient way. completely in memory. If processes dont fit in
memory, they are swapped in and out to run.
Sunbeam Infotech 2 Sunbeam Infotech 3
Web-Based Computing
Web has become ubiquitous
PCs most prevalent devices
More devices becoming networked to allow web
access
New category of devices to manage web traffic
among similar servers: load balancers
Use of operating systems like Windows 95, client-
side, have evolved into Linux and Windows XP, which
can be clients and servers
Sunbeam Infotech 22
destroy a mailbox
Blocking is considered synchronous
Mailbox sharing Blocking send has the sender block until the message
P1, P2, and P3 share mailbox A is received
P1, sends; P2 and P3 receive Blocking receive has the receiver block until a
Who gets the message? message is available
Solutions Non-blocking is considered asynchronous
Allow a link to be associated with at most two processes
Non-blocking send has the sender send the message
Allow only one process at a time to execute a receive
operation and continue
Allow the system to select arbitrarily the receiver. Sender Non-blocking receive has the receiver receive a valid
is notified who the receiver was. message or null
Buffering Client-Server Communication
Queue of messages attached to the link; Sockets
implemented in one of three ways Remote Procedure Calls
Zero capacity 0 messages
Remote Method Invocation (Java)
Sender must wait for receiver (rendezvous)
Bounded capacity finite length of n messages
Sender must wait if link full
Unbounded capacity infinite length
Sender never waits
SunBeam Infotech
Benefits of Multi-threading
Responsiveness Resource Sharing
Economy Utilization of MP Architecture
Java Threads
Java threads are managed by the JVM
Java threads may be created by:
Extending Thread class
Implementing the Runnable interface
Basic Concepts
Maximum CPU
utilization obtained
with multiprogramming
CPUI/O Burst Cycle
Process execution
consists of a cycle of
SunBeam Infotech CPU execution and I/O
wait
CPU burst distribution
P1 P3 P2 P4 P1 P2 P3 P2 P4 P1
0 3 7 8 12 16 0 2 4 5 7 11 16
v n ?1 ? c t n - *1 / c +v n . vn+1 = c tn
Only the actual last CPU burst counts
If we expand the formula, we get:
1. t n ? actual length of n th CPU burst vn+1 = c tn+(1 - c)c tn -1 +
2. v n -1 ? predicted value for the next CPU burst +(1 - c )j c tn -j +
3. c , 0 c 1 +(1 - c )n +1 v0
Since both c and (1 - c) are less than or equal to 1, each
4. Define : successive term has less weight than its predecessor
Priority Scheduling Round Robin (RR)
A priority number (integer) is associated with each Each process gets a small unit of CPU time (time
process quantum), usually 10-100 milliseconds. After this
The CPU is allocated to the process with the highest time has elapsed, the process is preempted and
priority (smallest integer highest priority) added to the end of the ready queue.
Preemptive If there are n processes in the ready queue and the
nonpreemptive time quantum is q, then each process gets 1/n of the
SJF is a priority scheduling where priority is the CPU time in chunks of at most q time units at once.
predicted next CPU burst time No process waits more than (n-1)q time units.
Problem Starvation low priority processes may Performance
never execute q large FIFO
Solution Aging as time progresses increase the
priority of the process q small q must be large with respect to context
switch, otherwise overhead is too high
R-R Scheduling : Time Quantum=20 time quantum & context switch time
Process Burst Time
P1 53
P2 17
P3 68
P4 24
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
Thread Scheduling
Local Scheduling How the threads library decides
which thread to put onto an available LWP
Global Scheduling How the kernel decides which
kernel thread to run next
OS Example: Windows XP Priorities OS Example: Linux Scheduling
Two algorithms: time-sharing and real-time
Time-sharing
Prioritized credit-based process with most credits is
scheduled next
Credit subtracted when timer interrupt occurs
When credit = 0, another process chosen
When all processes have credit = 0, recrediting occurs
Based on factors including priority and history
Real-time
Soft real-time
Posix.1b compliant two classes
FCFS and RR
Highest priority process always runs first
SunBeam Infotech
Background Producer
Concurrent access to shared data may result in data
inconsistency while (true) {
Maintaining data consistency requires mechanisms
to ensure the orderly execution of cooperating /* produce an item and put in nextProduced */
processes
while (count == BUFFER_SIZE)
Suppose that we wanted to provide a solution to the
consumer-producer problem that fills all the buffers. ; // do nothing
We can do so by having an integer count that keeps buffer [in] = nextProduced;
track of the number of full buffers. Initially, count is in = (in + 1) % BUFFER_SIZE;
set to 0. It is incremented by the producer after it count++;
produces a new buffer and is decremented by the
consumer after it consumes a buffer. }
6XQ%HDP,QIRWHFK
/
>D
E
6XQ%HDP,QIRWHFK 6XQ%HDP,QIRWHFK
6XQ%HDP,QIRWHFK 6XQ%HDP,QIRWHFK
!" #
,
/DDh
d
6XQ%HDP,QIRWHFK 6XQ%HDP,QIRWHFK
#
#
Z >
^
h ^
E K
^
6XQ%HDP,QIRWHFK 6XQ%HDP,QIRWHFK
6XQ%HDP,QIRWHFK 6XQ%HDP,QIRWHFK
& '( $)
D
Z
h
Z
>
DDh
6XQ%HDP,QIRWHFK 6XQ%HDP,QIRWHFK
&!&" #
)
D
,
,
&
t
K
W
t
W
&
6XQ%HDP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