QMCS 360
Class Notes # 6
Dr. Rick Smith
Quantitative Methods
and
Computer Science
Dr. Smith Home
|
Research
|
Classes
|
Blackboard
|
Cryptosmith
|
QMCS Home
|
UST A-Z
|
UST Home
last update:
Tuesday, September 27, 2005
Homework
Executing the Operating System
Options
Kernel runs as "itself" independent of process environment
Kernel runs as part of the user's process but in kernel mode
Kernel has its own processes
Running without a process
Need special mechanisms to do multi-step operations that pause and resume
Can't do file I/O directly
Need to do mode switch, but not process switch, to do OS services
Running in the user process
OS code running in user mode can do I/O subject to user's privileges
OS code needs to be visible to all processes
Need to do mode switches, but not process switches, to do OS services
Running own processes
Must do mode switch and process switch for some services
OS code can do I/O subject to process-specific privileges
OS code does not need to be in all processes address spaces
Enforces a modular design on the OS
least privilege
separation of duties
Good in a microkernel architecture - minimize amount of kernel code
Good in multiprocessor environment - distribute OS operations among processors
Threads and Processes
Distinction
A process has an entire "context" as we talked about earlier - states, queues, wait conditions, RAM allocations, device allocations, etc.
A thread has its processor context, a process state (run, wait, etc), and it may be on a queue - a "lightweight" process
What are threads for?
Foreground/background: foreground processes the GUI, background updates the window contents
Asynchronous operation - having part of the program read ahead from the hard drive so the data is already in RAM when needed
Network server - have one thread for each incoming connection
Thread operation
Typical states
Running
Ready
Blocked
Typical operations
Spawn
Block
Unblock
Finish
Thread implementation
User level threads
User program has its own dispatching software (in a library)
Scheduling and "interrupts" via "signal" operations
Library intercepts blocking I/O and substitutes for nonblocking I/O, then schedules a different thread - if the OS supports this
Allows for application-specific scheduling
Can't take advantage of multiprocessing
Kernel level threads
Kernel implements the threads - user program doesn't need its own scheduler and/or dispatcher
Kernel can schedule different threads on different processors
Blocking I/O doesn't block all threads - kernel can schedule another thread
Kernel thread switching / scheduling takes 10-30 times as long as user level switching
Combined approach
Implement user level threads and schedule them via 2 or more kernel level threads