Lec4 - ECE151 – Lecture 4 1 ECE151 – Lecture 4 Chapter...

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

Unformatted text preview: ECE151 – Lecture 4 1 ECE151 – Lecture 4 Chapter 3 Processes ECE151 – Lecture 4 2 Introduction to Threads Basic idea: we build virtual processors in software, on top of physical processors: Processor: Provides a set of instructions along with the capability of automatically executing a series of those instructions. Thread: A minimal software processor in whose context a series of instructions can be executed. Saving a thread context implies stopping the current execution and saving all the data needed to continue the execution at a later stage. Process: A software processor in whose context one or more threads may be executed. Executing a thread, means executing a series of instructions in the context of that thread. ECE151 – Lecture 4 3 Virtualization ECE151 – Lecture 4 4 Context Switching Processor context: The minimal collection of values stored in the registers of a processor used for the execution of a series of instructions (e.g., stack pointer, addressing registers, program counter). Thread context: The minimal collection of values stored in registers and memory, used for the execution of a series of instructions (i.e., processor context, state). Process context: The minimal collection of values stored in registers and memory, used for the execution of a thread (i.e., thread context, but now also at least MMU register values). ECE151 – Lecture 4 5 Context Switching Observation 1: Threads share the same address space. Thread context switching can be done entirely independent of the operating system. Observation 2: Process switching is generally more expensive than thread switching; it involves getting the OS in the loop, i.e., trapping to the kernel. Observation 3: Creating and destroying threads is much cheaper than doing so for processes. ECE151 – Lecture 4 6 Threads and Operating Systems Main issue: Should an OS kernel provide threads, or should they be implemented as user-level packages? User-space solution: We’ll have nothing to do with the kernel, so all operations can be completely handled within a single process implementations can be extremely efficient. All services provided by the kernel are done on behalf of the process in which a thread resides if the kernel decides to block a thread, the entire process will be blocked. Requires messy solutions. In practice we want to use threads when there are lots of external events: threads block on a per-event basis if the kernel can’t distinguish threads, how can it support signaling events to them. ECE151 – Lecture 4 7 Threads and Operating Systems Kernel solution: The whole idea is to have the kernel contain the implementation of a thread package. This does mean that all operations return as system calls Operations that block a thread are no longer a problem: the kernel schedules another available thread within the same process....
View Full Document

This note was uploaded on 05/04/2008 for the course ECE 151 taught by Professor Melliar-smith during the Spring '08 term at UCSB.

Page1 / 45

Lec4 - ECE151 – Lecture 4 1 ECE151 – Lecture 4 Chapter...

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

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