Presentation is loading. Please wait.

Presentation is loading. Please wait.

January 15, 2004 Adrienne Noble

Similar presentations


Presentation on theme: "January 15, 2004 Adrienne Noble"— Presentation transcript:

1 January 15, 2004 Adrienne Noble
Week 2 January 15, 2004 Adrienne Noble

2 Questions? Lecture Homework Project – Due tomorrow by 2:30!
Mention names when answering questions Office hours: Wednesday 1-2 in 006 Also, feel free to come ask me questions when you see me around the lab – if I happen to be busy, I’ll tell you Lecture: Ed’s been going over a lot of higher level stuff, but realize that you aren’t expected to be experts on threads, critical sections, paging, file systems, etc. We’ll go over most of those in much more detail as the quarter progresses. Just a big overview right now. Homework: probably haven’t started yet, but any questions? Project: stress importance of writeup – almost half of total points Shell: 15 points System call: 15 points Write-up: 25 points

3 Waiting for I/O Your computer is often waiting on many devices at once: File Socket Keyboard All these devices are represented by a file descriptor A file descriptor (fd) is given to each device so that you can perform operations like reading from that device What are some methods you could use to read these devices when they’re ready?

4 Polling Just loop around and check each fd Advantages Disadvantages
Simple to understand, easy to implement Disadvantages Slow, can only read one fd at a time, doesn’t necessarily read fds in order that they have data available, busy waiting What do I mean by saying it doesn’t read fds in the order that they have data available? What about busy waiting?

5 Select Give it all the fds, then it blocks and returns when a fd is ready to read Advantages Immediate notification that a fd is ready, no busy waiting Disadvantages Can still only read one at a time You may have seen it in Networks

6 What is a process? A single instance of a running program
Every process has it’s own memory space (static data, stack, heap, and code) Process Control Block (PCB), which holds lots of state information Ask someone to outline the method of creating a new process

7 Fork (multiple processes)
Create a separate process for each fd Advantages Can read multiple fds at once, always knows right away when something is ready, inter-process communication Disadvantages Lots of overhead (in creation and switching), more complicated, expensive communication Are we really doing multiple things at once? No, but the OS switches around a lot What happens when a process is created or switched? Requires flushing the cache and TLB – both expensive operations

8 What is a thread? Often called a lightweight process
Shares many resources with the process Code, heap, etc But has it’s own stack, program counter, and registers Much less expensive to create and switch between Why not always use threads and just get rid of processes completely? Might not always want to share data like threads do

9 Threads Create a separate thread for each fd Advantages Disadvantages
Much less overhead, fast, lightweight, good communication between threads Disadvantages Shared data, more complicated More about project

10 Project Details Groups of 3 Start early!
First part is due two weeks from tomorrow Implement a user thread package Write synchronization primitives for those threads (mutex, condition variables) This weekend might be a good time to get acquainted with the project read the project page looks through the code start designed your thread implementation


Download ppt "January 15, 2004 Adrienne Noble"

Similar presentations


Ads by Google