Lecture17nFull - Click to edit Master subtitle style 8/1/11...

Info iconThis preview shows pages 1–7. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Click to edit Master subtitle style 8/1/11 Lecture 17 COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM Lecture 17 8/1/11 n Last time: n Threads n Thread state n Processor switching - YIELD system call n Today: n Processor switching n Communication with a bounded buffer Next time n Communication with a bounded buffer n Semaphores n Deadlocks Lecture 17 Thursday, March 24, 2011 Lecture 17 22 Lecture 17 8/1/11 YIELD n System call executed by the kernel at the request of an application allows an active thread A to voluntarily release control of the processor. n YIELD invokes the ENTER_PROCESSOR_LAYER procedure locks the thread table and unlock it when it finishes it work changes the state of thread A from RUNNING to RUNNABLE invokes the SCHEDULER the SCHEDULER searches the thread table to find another tread B in RUNNABLE state the state of thread B is changed from RUNNABLE to RUNNING the registers of the processor are loaded with the ones saved on the stack for thread B thread B becomes active n Why is it necessary to lock the thread table? We may have multiple cores/processors so another thread my be active. An interrupt may occur n The pseudo code assumes that we have a fixed number of threads , 7. n The flow of control YIELD& ENTER_PROCESSOR_LAYERF SCHEDULERT EXIT_PROCESSOR_LAYER& YIELD Lecture 17 33 Lecture 17 8/1/11 O bj1 0 44 Lecture 17 Lecture 17 8/1/11 Dynamic thread creation and termination n Until now we assumed a fixed number, 7 threads; the thread table was of fixed size. n We have to support two other system calls: EXIT_THREAD & Allow a tread to self-destroy and clean-up DESTRY_THREAD & Allow a thread to terminate another thread of the same application Lecture 17 55 Lecture 17 8/1/11 Important facts to remember n Each thread has a unique ThreadId n Threads save their state on the stack. n The stack pointer of a thread is stored in the thread table. n To activate a thread the registers of the processor are loaded with information from the thread state. n 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 n We have a processor thread for each processor/core....
View Full Document

Page1 / 25

Lecture17nFull - Click to edit Master subtitle style 8/1/11...

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

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