Lecture7 - COP 5611 Operating Systems Spring 2010 Dan C....

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 5611 Operating Systems Spring 2010 Dan C. Marinescu Office: HEC 439 B Office hours: M-Wd 2:00-3:00 PM
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Lecture 7 Last time: Thread coordination Today: Thread coordination Scheduling Multi-level memories I/O bottleneck Next Time:
Background image of page 2
Hardware support for atomic actions RSM (Read and Set Memory) instruction TST (Test and Set) instruction Two primitives: ACQUIRE (lock) RELEASE (lock) use atomic instructions to manipulate the lock.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lecture 6 4
Background image of page 4
Processor sharing strategies The previous solution assume that each thread runs on a different processor and have the luxury of a spin lock and busy wa it. Now we consider sharing a processor among several threads and need several new functions: Strategy 1: a thread voluntary releases the control of the processor Allow a thread to wait for an event; Allow several threads running on the same processor to wait for a lock. Strategy 2: force a thread to release the control of the processor What needs to be done to switch the processor from one thread to another: Save the state of the current thread Schedule another thread Start running the new thread 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The kernel The role of a kernel: controls virtualization Processor sharing among threads Virtual memory management I/O operations Two modes of running: user (unprivileged) + kernel (privileged) Two types of threads: user-layer threads + processor-layer threads. Open questions How to create and terminate a thread? If multiple threads are RUNNABLE who decides which one gets control of the processor? What if no threads are ready to run? 6
Background image of page 6
The procedure followed when a kernel starts Procedure RUN_PROCESSORS() for each processor do allocate stack and setup processor thread /*allocation of the stack done at processor layer */ shutdown FALSE SCHEDULER() deallocate processor_thread stack /*deallocation of the stack done at processor layer */ halt processor
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The processor_thread and the SCHEDULER Thread creation : thread_id ALLOCATE_THREAD(starting_address_of_procedure, address_space_id); What if want to create/terminate threads dynamically we have to: Allow a tread to self-destroy and clean-up -> EXIT_THREAD Allow a thread to terminate another thread of the same application DESTROY_THREAD What if no thread is able to run create a dummy thread for each processor called a processor_thread which is scheduled to run when no other thread is available the processor_thread runs in the thread layer the SCHEDULER runs in the processor layer 8
Background image of page 8
Switching from one user-thread to another requires two steps 1. Switch from the user-thread releasing the processor to the processor-thread 2. Switch from the processor thread to the new use-thread which is going to have the control of the processor. This step requires the SCHEDULER to circle through the thread_table
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 35

Lecture7 - COP 5611 Operating Systems Spring 2010 Dan C....

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online