Professional Documents
Culture Documents
Sunbeam Infotech
Sunbeam Infotech
Operating system
Users
Sunbeam Infotech
OS is a resource allocator
OS is a control program
Sunbeam Infotech
Hard disks
PATA / IDE
SATA
Partitions
Boot options:
FAT / FAT32
NTFS
EXT2 / EXT3
HFS
10
Installing Windows OS
Logical partition
Extended partition
File system
Primary partition
CD/DVD drive
Disk drive
USB drive
Network boot
Sunbeam Infotech
Sunbeam Infotech
Disk configurations
Primary Master
Primary Slave
Secondary Master
Secondary Slave
BIOS settings
(Windows OS)
(Windows Server OS)
(Linux OS)
(MAC OS)
11
12
13
Bootable device
bootstrap program
Sunbeam Infotech
15
16
Sunbeam Infotech
18
Booting process
17
Sunbeam Infotech
Sunbeam Infotech
Computer-System Operation
I/O Structure
Device-Status Table
wait instruction or loop idles the CPU until the next interrupt
At most one I/O request is outstanding at a time, no
simultaneous I/O processing.
Sunbeam Infotech
Storage Structure
Sunbeam Infotech
10
Sunbeam Infotech
Magnetic Disks
Sunbeam Infotech
Magnetic Disks
Sunbeam Infotech
Main Memory
11
Sunbeam Infotech
12
Storage-Device Hierarchy
Caching
Sunbeam Infotech
Sunbeam Infotech
Sunbeam Infotech
15
Dual-Mode Operation
Dual-Mode Operation
I/O Protection
Memory Protection
CPU Protection
Sunbeam Infotech
16
14
Hardware Protection
13
17
Sunbeam Infotech
18
I/O Protection
Memory Protection
21
Sunbeam Infotech
Sunbeam Infotech
20
CPU Protection
When executing in
monitor mode, the
operating system has
unrestricted access to
both monitor and users
memory.
The load instructions
for the base and limit
registers are privileged
instructions.
Sunbeam Infotech
19
23
22
Multiprogramming
Multitasking
Mainframe Systems
Desktop Systems
Multiprocessor Systems
Distributed Systems
Real -Time Systems
Handheld Systems
Sunbeam Infotech
Multiprogrammed systems
Resident monitor
Mainframe Systems
Desktop Systems
Batch systems
Sunbeam Infotech
Mainframe Systems
multi-processing
multi-threading
Multiprogramming System
Sunbeam Infotech
Sunbeam Infotech
Multiprocessor Systems
Distributed Systems
Asymmetric multiprocessing
Sunbeam Infotech
10
Sunbeam Infotech
Process Management
Memory Management
Storage Management
File System Management
I/O System Management
Protection and Security
User interfacing
Sunbeam Infotech
11
Process Management
Limited memory
Slow processors
Small display screens
Issues:
Sunbeam Infotech
Soft real-time
Handheld Systems
12
Sunbeam Infotech
13
Memory Management
Storage Management
16
15
Sunbeam Infotech
I/O Management
14
Free-space management
Storage allocation
Disk scheduling
File 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
Most modern computer systems use disks as the principle online storage medium, for both programs and data.
Entire speed of computer operation hinges on disk subsystem
and its algorithms
OS activities
Sunbeam Infotech
17
Computing Environments
Traditional computer
Home networks
Peer-to-Peer Computing
21
22
23
Sunbeam Infotech
25
Web-Based Computing
Sunbeam Infotech
24
System Calls
Sunbeam Infotech
MS-DOS Execution
Free-BSD UNIX
multiprogramming
Process control
File management
Device management
Information maintenance
Communications
System programs
File manipulation
File modification
Status information
Programming language support
Program loading and execution
Communications
Application programs
Programming-language support
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
Status information
Layered Structure
MS-DOS written to
provide the most
functionality in the least
space
UNIX System
Uses object-oriented
approach
Each core component is
separate
Each talks to the others
over known interfaces
Each is loadable as needed
within the kernel
Virtual Machines
CPU scheduling can create the appearance that users have their own
processor
Spooling and a file system can provide virtual card readers and virtual
line printers
A normal user time-sharing terminal serves as the virtual machine
operators console
Sunbeam Infotech
AND
22
VMware Architecture
While generating
machine code,
compiler assumes
certain machine
configuration. This
machine assumed
as virtual machine.
JAVA compiler
assumes JVM and
creates byte code,
that is executed on
JVM installed on
host system.
Process Concept
An OS executes a variety of
programs:
SunBeam Infotech
Process State
program counter
stack
data section
Process state
Program counter
CPU registers
CPU scheduling information
Memory-management
information
Accounting information
I/O status information
Schedulers
Context Switch
Process Creation
Execution
Address space
UNIX examples
Process Termination
Cooperating Processes
Information sharing
Modularity
Computation speed-up
Convenience
Implementing IPC
Implementation questions:
Direct Communication
Communications Models
Indirect Communication
Indirect Communication
Operations
create a new mailbox
send and receive messages through mailbox
destroy a mailbox
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 arbitrarily the receiver. Sender
is notified who the receiver was.
Synchronization
Buffering
Sockets
Remote Procedure Calls
Remote Method Invocation (Java)
Sockets
Client-Server Communication
A socket is defined as
an endpoint for
communication
Concatenation of IP
address and port
The socket
161.25.19.8:1625 refers
to port 1625 on host
161.25.19.8
Communication
consists between a pair
of sockets
Marshalling Parameters
SunBeam Infotech
User threads
Benefits of Multi-threading
Responsiveness
Resource Sharing
Economy
Utilization of MP Architecture
Thread management
done by user-level
threads library
Three primary thread
libraries:
POSIX Pthreads
Win32 threads
Java threads
Vs Kernel threads
Supported by the
Kernel
Examples
Windows XP/2000
Solaris
Linux
Tru64 UNIX
Mac OS X
Threading Issues
Windows NT/XP/2000
Linux
Similar to M:M,
except that it
allows a user
thread to be
bound to kernel
thread
Examples
IRIX
HP-UX
Tru64 UNIX
Solaris 8 and
earlier
Thread cancellation
Options:
Threading Issues
Thread pools
Java Threads
Scheduler activations
Threading Issues
Windows XP Threads
A thread id
Register set
Separate user and kernel stacks
Private data storage area
Basic Concepts
SunBeam Infotech
CPU Scheduler
Dispatcher
Scheduling Criteria
Maximum CPU
utilization obtained
with multiprogramming
CPUI/O Burst Cycle
Process execution
consists of a cycle of
CPU execution and I/O
wait
CPU burst distribution
switching context
switching to user mode
jumping to the proper location in the user program to
restart that program
FCFS Scheduling
Process Burst Time
P1
24
P2
P3
P1
0
P2
24
P3
27
30
P2
P3
P1
30
Burst Time
P1
0.0
P2
P3
2.0
4.0
4
1
P2
P3
2.0
4.0
4
1
P4
5.0
P4
5.0
P3
7
P1
P4
P2
12
16
SJF (non-preemptive)
Average waiting time = (0 + 6 + 3 + 7)/4 = 4
Burst Time
0.0
P1
P1
v n ?1 ? c t n - *1 / c +v n .
1. t n ? actual length of n th CPU burst
P3
4
P2
5
P1
P4
7
11
16
SJF (non-preemptive)
Average waiting time = (9 + 1 + 0 +2)/4 = 3
3. c , 0 c 1
4. Define :
P2
c =0
vn+1 = vn
Recent history does not count
c =1
vn+1 = c tn
Only the actual last CPU burst counts
If we expand the formula, we get:
vn+1 = c tn+(1 - c)c tn -1 +
+(1 - c )j c tn -j +
+(1 - c )n +1 v0
Since both c and (1 - c) are less than or equal to 1, each
successive term has less weight than its predecessor
Priority Scheduling
Preemptive
nonpreemptive
q large FIFO
q small q must be large with respect to context
switch, otherwise overhead is too high
P1
0
P2
20
37
P3
P1
53
P2
17
P3
68
P4
24
P4
57
P1
77
P3
P4
97 117
P1
P3
P3
Multilevel Queue
background (batch)
foreground RR
background FCFS
number of queues
scheduling algorithms for each queue
method used to determine when to upgrade a process
method used to determine when to demote a process
method used to determine which queue a process will
enter when that process needs service
Three queues:
Scheduling
Thread Scheduling
Scheduling Environments
Scheduling Environments
Real-time
Algorithm Evaluation
Deterministic
modeling takes
a particular
predetermined
workload and
defines the
performance of
each algorithm
for that workload
Queueing models
Implementation
SunBeam Infotech
Background
Producer
while (true) {
/* produce an item and put in nextProduced */
while (count == BUFFER_SIZE)
; // do nothing
buffer [in] = nextProduced;
in = (in + 1) % BUFFER_SIZE;
count++;
}
Consumer
while (true) {
while (count == 0)
; // do nothing
nextConsumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
count--;
/* consume the item in nextConsumed
}
Race Condition
count++ could be
implemented as
register1 = count
register1 = register1 + 1
count = register1
count-- could be
implemented as
register2 = count
register2 = register2 - 1
count = register2
Petersons Solution
int turn;
Boolean flag[2]
Synchronization Hardware
Bounded-Buffer Problem
P1
wait (Q);
wait (S);
.
signal (Q);
signal (S);
wait (S) {
while S <= 0
; // no-op
S--;
}
signal (S) {
S++;
}
Less complicated
Can only be accessed via two
indivisible (atomic)
operations
Semaphore Implementation
Semaphore S; // initialized to 1
wait (S);
Critical Section
signal (S);
Atomic = non-interruptable
Semaphore
Dining-Philosophers Problem
??
Dining-Philosophers Problem
Monitors
procedure Pn () {}
Initialization code ( .) { }
}
}
condition x, y;
Two operations on a
condition variable:
x.wait () a process
that invokes the
operation is
suspended
x.signal () resumes
one of processes (if
any) that invoked
x.wait ()
Solaris Synchronization
Windows XP Synchronization
Linux:
Linux provides:
mutex locks
condition variables
read-write locks
spin locks
Transaction name
Old value
Log-Based Recovery
semaphores
spin locks
System Model
Pthreads Synchronization
Linux Synchronization
wait (A);
wait (B);
P1
wait(B)
wait(A)
Deadlock Characterization
Example
Deadlock Prevention
No Preemption
Deadlock Avoidance
6XQ%HDP,QIRWHFK
6XQ%HDP,QIRWHFK
/
>D
E
6XQ%HDP,QIRWHFK
d
6XQ%HDP,QIRWHFK
> Wh
W
>
6XQ%HDP,QIRWHFK
#
!"
,
/DDh
d
6XQ%HDP,QIRWHFK
#
6XQ%HDP,QIRWHFK
#
Z
h
E
6XQ%HDP,QIRWHFK
$
>
^
^
K
^
6XQ%HDP,QIRWHFK
%$$
Z
D
D
hE/y>t
^
6XQ%HDP,QIRWHFK
6XQ%HDP,QIRWHFK
&
D
Z
h
Z
>
DDh
6XQ%HDP,QIRWHFK
&!&"
6XQ%HDP,QIRWHFK
#
)
D
,
t
K
,
&
6XQ%HDP,QIRWHFK
^
/K
&
&
/&
Z
W
*
W
t
6XQ%HDP,QIRWHFK
>/K
/KK^
6XQ%HDP,QIRWHFK
>
<<
<
d
^
/
6XQ%HDP,QIRWHFK
' $
Wh
W
W
SDJHQXPEHU
SDJHRIIVHW
P Q
&
6XQ%HDP,QIRWHFK
6XQ%HDP,QIRWHFK
6XQ%HDP,QIRWHFK
,-!./ )
0 )
"
* *
6XQ%HDP,QIRWHFK
1+)
6XQ%HDP,QIRWHFK
W
WWdZ
WWZ>Z
/
K
d
d>
^d> ^/
d>
6XQ%HDP,QIRWHFK
/
K
6XQ%HDP,Q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