OS Structure

download report

Transcript OS Structure

Operating System Structure
• OS provides a structure in which programs
• Multiprogramming 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
Memory Layout for Multiprogrammed System
Process Scheduling Queues
• Job queue
– set of all processes in the system
• Ready queue
– set of all processes residing in main memory,
ready and waiting to execute
• Device queue
– set of processes waiting for an I/O device
• Long-Term Scheduler (job scheduler)
– Selects which processes should be brought into the
ready queue
– Controls the degree of multiprogramming
– Invoked very infrequently
• Short-Term Scheduler (CPU scheduler)
– Selects which process should be executed next and
allocates the CPU to it
– Invoked very frequently. How fast should it be?
• Keep the CPU as busy as possible!
• Maximum CPU utilization obtained with
• Will cover CPU scheduling in chapter 4
• Timesharing (multitasking) is a logical extension of
multiprogramming in which CPU switches jobs so frequently
that users can interact with each job while it is running,
creating interactive computing
Response time should be < 1 second
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
– Virtual memory allows execution of processes not completely in
• Running multiple jobs concurrently requires
that their ability to affect one another be
– Concurrent access to shared data may result in
data inconsistency
– Maintaining data consistency requires
mechanisms to ensure the orderly execution of
– Will cover process synchronization in chapter 7
• We also have the problem of deadlock
– A set of blocked processes each holding a resource and waiting to
acquire a resource held by another process in the set
– An example involving processes?
– Will cover deadlock in chapter 8
Dual-mode Operation
• Allows OS to protect itself and other system
– User mode and kernel mode
– Mode bit provided by hardware
• Provides ability to distinguish when system is running
user code or kernel code
• Some instructions designated as privileged, only
executable in kernel mode
• System call changes mode to kernel, return from call
resets it to user
Transition from User to Kernel Mode
• Timer to prevent infinite loop / process hogging
– Set interrupt after specific period
– Set up before scheduling process to regain control or
terminate program that exceeds allotted time