Lec4_thread

Lec4_thread - Announcement CSE120 Principles of Operating Systems Homework 1 released this week(optional Project 0 due today Prof Yuanyuan(YY Zhou

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

View Full Document Right Arrow Icon
1 CSE120 Principles of Operating Systems Prof Yuanyuan (YY) Zhou Lecture 4: Threads Oct 5th, 2010 10/4/2010 CSE 120 – Lecture 4 – Threads 2 Announcement Homework 1 released this week ( optional) Project 0 due today 10/4/2010 CSE 120 – Lecture 4 – Threads 3 Processes Recall that a process includes many things An address space (defining all the code and data pages) OS resources (e.g., open files) and accounting information Execution state (PC, SP, regs, etc.) Creating a new process is costly because of all of the data structures that must be allocated and initialized Recall struct proc in Solaris …which does not even include page tables, perhaps TLB flushing, etc. Communicating between processes is costly because most communication goes through the OS Overhead of system calls and copying data 10/4/2010 CSE 120 – Lecture 4 – Threads 4 Parallel Programs To execute these programs we need to Create several processes that execute in parallel Cause each to map to the same address space to share data Have the OS schedule these processes in parallel (logically or physically) This situation is very inefficient Space : PCB, page tables, etc. Time : create data structures, fork and copy addr space, etc.
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 10/4/2010 CSE 120 – Lecture 4 – Threads 5 Rethinking Processes What is similar in these cooperating processes? They all share the same code and data (address space) They all share the same privileges They all share the same resources (files, sockets, etc.) What don’t they share? Each has its own execution state: PC, SP, and registers Key idea : Why don’t we separate the concept of a process from its execution state? Process : address space, privileges, resources, etc. Execution state : PC, SP, registers Exec state also called thread of control , or thread 10/4/2010 CSE 120 – Lecture 4 – Threads 6 Threads Modern OSes (Mach, Chorus, NT, modern Unix) separate the concepts of processes and threads The thread defines a sequential execution stream within a process (PC, SP, registers) The process defines the address space and general process attributes (everything but threads of execution) A thread is bound to a single process A process, however, can have multiple threads Threads become the unit of scheduling Processes are now the containers in which threads execute Processes become static, threads are the dynamic entities 10/4/2010 CSE 120 – Lecture 4 – Threads 7 Threads: Lightweight Processes A sequential execution stream within a process (a) Three processes each with one thread (b) One process with three threads Environment (resource) execution 10/4/2010 CSE 120 – Lecture 4 – Threads 8 The Thread Model Shared information Processor info: parent process, time, etc Memory: segments, page table, and stats, etc I/O and file: comm ports, directories and file descriptors, etc Why?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/09/2010 for the course CSE CSE 120 taught by Professor Yuanyuanzhou during the Spring '10 term at UCSD.

Page1 / 9

Lec4_thread - Announcement CSE120 Principles of Operating Systems Homework 1 released this week(optional Project 0 due today Prof Yuanyuan(YY Zhou

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

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