Threads

Chapter 6 CDK begins with discussion on operating system structure which we discussed previously.

Also talks about naming a little and virtual memory with external pagers. Not the focus of this material.








Goes on to talk about processes and threads. Fig 6.4 is interesting with regard to terminology:

Distributed OS kernel Thread name Exec. Env. Name
Amoeba Thread Process
Chorus Thread Actor
Mach Thread Task
V System Process Team
Unix - Process
Linux Shared-memory Task Task

Threads vs. Processes

Threads

Also called lightweight processes. Contain an execution state within a shared address space.

Threads are natural to use for a server handling requests. Each request can be handled by a thread.

Synchronization primitives:

Scheduling:
Can use either preemptive or non-preemptive scheduling. Why one over the other? Same issue as with process scheduling? Closer coordination. Preemptive scheduling does not seem as crucial.

Implementation Issues

User vs. Kernel threads. Fig 12-8 (from perspective of user threads):

can implement on a system not supporting kernel threads
fast creation of threads (kernel not involved)
fast switching between threads (kernel not involved)
customized scheduling algorithm
$-$
must have jackets around system calls that may block
$-$
no clock interrupts for time slicing
$-$
use threads when there are many system calls, not much more work to switch threads in the kernel.
$-$
do not gain on a multiprocessor.
$-$
for all threads, worry about non-reentrant code (errno).

Specific examples of calls in CDK text.

Global Scheduling

Can show both theoretically and practically that many idle nodes exist at any one time. Look at Fig 11.1 and 11.2 from Singhal.

What is performance we are trying to optimize?

Issues:

Components

Examples

Co-Scheduling

co-scheduling or gang scheduling to get processes that are cooperating to run at the same time.

Requirements for Load Sharing

Task Migration

State transfer and then unfreeze

Load Sharing

Examine ELZ paper.

Memory Management

Look at memory management on a multiprocessor and a distributed system.

Multiprocessor

Two models

  1. Shared memory, uniform access

    Look at cache affinity paper for processor scheduling.

  2. Non-uniform memory.

Server Scheduling

Cache affinity for task scheduling in server. Slides: http://www.cs.wpi.edu/~cs535/s03/larus:usenix02/