Lec4 - ECE151 Lecture 4 Chapter 3 Processes ECE151 Lecture...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE151 – Lecture 4 1 ECE151 – Lecture 4 Chapter 3 Processes
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
ECE151 – Lecture 4 3 Virtualization
Image of page 3

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

View Full Document Right Arrow Icon
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).
Image of page 4
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.
Image of page 5

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

View Full Document Right Arrow Icon
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.
Image of page 6
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.
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern