{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ECE344-Lecture6-Threads - Lecture 6 Threads David Lie...

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

View Full Document Right Arrow Icon
1 Lecture 6: Threads David Lie ECE344 University of Toronto
Background image of page 1

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

View Full Document Right Arrow Icon
2 ECE344: Operating Systems Overview Thread Implementation Thread scheduling Thread creation and termination Kernel threads vs. user threads
Background image of page 2
3 ECE344: Operating Systems Threads and Processes Processes can have multiple thread within them: All these threads share OS state and address space OS state includes open files, network sockets, etc… Switching between threads is more efficient: No need to switch address spaces Why is switching address spaces expensive? Modern operating systems can be more flexible: Example: Linux clone system call allows partial sharing Can share files, address space, signal handlers, etc…
Background image of page 3

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

View Full Document Right Arrow Icon
4 ECE344: Operating Systems OS-level Thread State OS keeps state for each thread in a thread structure Alternate name: process control block (PCB) What is this state? Processor registers, allows suspending and resuming thread Thread id, uniquely identifies thread Various parameters, e.g., scheduling parameters Address space state, i.e., location of text, data, stack regions Virtual memory state, i.e., MMU state, page tables File state, e.g., open files, network connections OS keeps this state even when thread is not running User program cannot directly modify this state
Background image of page 4
5 ECE344: Operating Systems OS-level Thread state Thread Structure maintains all thread state. struct thread { /**********************************************************/ /* Private thread members - internal to the thread system */ /**********************************************************/ struct pcb t_pcb; char *t_name; char *t_stack; const void *t_sleepaddr;
Background image of page 5

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

View Full Document Right Arrow Icon
6 ECE344: Operating Systems Thread Scheduling States
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}