Lecture7 - OP 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

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: OP 5611 Operating Systems Spring 2010 Dan C. Marinescu Office: HEC 439 B Office hours: M-Wd 2:00-3:00 PM 2 Lecture 7 ¡ Last time: Thread coordination ¡ Today: ¢ Thread coordination ¢ Scheduling ¢ Multi-level memories ¢ I/O bottleneck ¡ Next Time: 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. Lecture 6 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 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 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 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 Switching threads with dynamic thread creation ¡ 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 until a thread ready to run is found ¡ The boundary between user-layer threads and processor-layer thread is crossed twice 9 10...
View Full Document

This note was uploaded on 07/30/2011 for the course COP 5611 taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 35

Lecture7 - OP 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