Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 3 January 22, 2004 Adrienne Noble. Today CVS – a great tool to use with your groups Threads – basic thread operations Intro to synchronization Hand.

Similar presentations


Presentation on theme: "Week 3 January 22, 2004 Adrienne Noble. Today CVS – a great tool to use with your groups Threads – basic thread operations Intro to synchronization Hand."— Presentation transcript:

1 Week 3 January 22, 2004 Adrienne Noble

2 Today CVS – a great tool to use with your groups Threads – basic thread operations Intro to synchronization Hand back Project 1

3 Questions? Lecture Homework 3 – Due Wed, Jan 28 Project 2 – Due Mon, Feb 2 Everyone should be signed up for a group by now

4 Why use CVS? The other way: Keep every version of code, all with different names: Project2good Project2_1_22_04 Project2working adrienneProject2_Feb_2 Project_old Send emails back and forth with new changes Merge different versions by hand The CVS way: One version, saved in the CVS repository Multiple people can work on the same file concurrently CVS merges the edited versions together as you put them back in the repository

5 Setting up CVS Set up CVS root Export CVSROOT=/cse451/groupa/ Initialize a repository cvs init Add your files cd into the directory of files you want to add cvs import –m “initial code” project2 vendor release

6 CVS Commands cvs checkout Checks out the module into your current directory cvs update [files…] Updates your checked out module by merging it with new changes cvs commit [files…] Saves your edited files in the repository cvs add [files…] Adds a new file to the repository More info at http://www.cvshome.org

7 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 than processes

8 Kernel Threads Kernel schedules and runs threads Usually scheduled like any other process Must switch into kernel mode for every context switch

9 User Threads Run completely in user space within one process Can make them faster than kernel threads Lets programmer have more flexibility in scheduling

10 Basic Thread Operations init() create( ) exit() yield() struct _thread { }

11 Synchronization What does synchronization do? Why do we need it?

12 Mutexes, Semaphores, Condition Variables, Monitors… Lots of names for things that do very similar things The goal is to protect shared data from being accessed by more than one thread at once They just have different features Each has advantages and disadvantages in different situations

13 Mutex (lock) Only allows one thread to access the shared data at a time Two functions: lock and unlock Basic Idea: Get lock (call lock function) Access shared data Give up lock (call unlock function)

14 Mutex Examples Withdrawing money from a bank account Reserving a concert ticket

15 Condition Variables Lets a thread wait for a certain condition or event to occur while holding a mutex Two functions: wait and signal Basic Idea: Thread with the lock calls wait The thread gives up the lock, then goes to sleep on the condition variable’s queue Someone calls signal to say that the event or condition has occurred A thread wakes up from the queue, obtains the lock again, and then continues

16 Project 1 Spend some time on the write up Error checking is important chdir, fork, execvp, your syscall, copy_to_user Read directions carefully Turn in the correct stuff in the correct format


Download ppt "Week 3 January 22, 2004 Adrienne Noble. Today CVS – a great tool to use with your groups Threads – basic thread operations Intro to synchronization Hand."

Similar presentations


Ads by Google