DOC PREVIEW
Berkeley COMPSCI 162 - Lecture 9 Tips for Working in a Project Team/ Cooperating Processes and Deadlock

This preview shows page 1-2-16-17-18-33-34 out of 34 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS162 Operating Systems and Systems Programming Lecture 9 Tips for Working in a Project Team/ Cooperating Processes and DeadlockReview: Definition of MonitorReview: Programming with MonitorsGoals for TodayTips for Programming in a Project TeamBig ProjectsTechniques for Partitioning TasksCommunicationCoordinationHow to Make it Work?Suggested Documents for You to MaintainUse Software ToolsTest ContinuouslyAdministriviaC++ Language Support for SynchronizationC++ Language Support for Synchronization (con’t)Java Language Support for SynchronizationJava Language Support for Synchronization (con’t)Java Language Support for Synchronization (con’t 2)Slide 20ResourcesStarvation vs DeadlockConditions for DeadlockBridge Crossing ExampleTrain Example (Wormhole-Routed Network)Dining Lawyers ProblemFour requirements for DeadlockResource-Allocation GraphResource Allocation Graph ExamplesMethods for Handling DeadlocksDeadlock Detection AlgorithmWhat to do when detect deadlock?SummarySummary (2)CS162Operating Systems andSystems ProgrammingLecture 9 Tips for Working in a Project Team/ Cooperating Processes and Deadlock September 26, 2008Prof. John Kubiatowiczhttp://inst.eecs.berkeley.edu/~cs162Lec 9.29/29/08 Kubiatowicz CS162 ©UCB Fall 2007Review: Definition of Monitor•Semaphores are confusing because dual purpose:–Both mutual exclusion and scheduling constraints–Cleaner idea: Use locks for mutual exclusion and condition variables for scheduling constraints•Monitor: a lock and zero or more condition variables for managing concurrent access to shared data–Use of Monitors is a programming paradigm•Lock: provides mutual exclusion to shared data:–Always acquire before accessing shared data structure–Always release after finishing with shared data•Condition Variable: a queue of threads waiting for something inside a critical section–Key idea: allow sleeping inside critical section by atomically releasing lock at time we go to sleep–Contrast to semaphores: Can’t wait inside critical sectionLec 9.39/29/08 Kubiatowicz CS162 ©UCB Fall 2007Review: Programming with Monitors•Monitors represent the logic of the program–Wait if necessary–Signal when change something so any waiting threads can proceed•Basic structure of monitor-based program:lock while (need to wait) { condvar.wait();}unlockdo something so no need to waitlockcondvar.signal();unlockCheck and/or updatestate variablesWait if necessaryCheck and/or updatestate variablesLec 9.49/29/08 Kubiatowicz CS162 ©UCB Fall 2007Goals for Today•Tips for Programming in a Project Team•Language Support for Synchronization•Discussion of Deadlocks–Conditions for its occurrence–Solutions for breaking and avoiding deadlockNote: Some slides and/or pictures in the following areadapted from slides ©2005 Silberschatz, Galvin, and Gagne Note: Some slides and/or pictures in the following areadapted from slides ©2005 Silberschatz, Galvin, and Gagne. Many slides generated from my lecture notes by Kubiatowicz.Lec 9.59/29/08 Kubiatowicz CS162 ©UCB Fall 2007Tips for Programming in a Project Team•Big projects require more than one person (or long, long, long time)–Big OS: thousands of person-years!•It’s very hard to make software project teams work correctly–Doesn’t seem to be as true of big construction projects»Empire state building finished in one year: staging iron production thousands of miles away»Or the Hoover dam: built towns to hold workers–Is it OK to miss deadlines? »We make it free (slip days)»Reality: they’re very expensive as time-to-market is one of the most important things!“You just have to get your synchronization right!”Lec 9.69/29/08 Kubiatowicz CS162 ©UCB Fall 2007Big Projects•What is a big project?–Time/work estimation is hard–Programmers are eternal optimistics (it will only take two days)!»This is why we bug you about starting the project early»Had a grad student who used to say he just needed “10 minutes” to fix something. Two hours later…•Can a project be efficiently partitioned?–Partitionable task decreases in time asyou add people–But, if you require communication:»Time reaches a minimum bound»With complex interactions, time increases!–Mythical person-month problem:»You estimate how long a project will take»Starts to fall behind, so you add more people»Project takes even more time!Lec 9.79/29/08 Kubiatowicz CS162 ©UCB Fall 2007Techniques for Partitioning Tasks•Functional–Person A implements threads, Person B implements semaphores, Person C implements locks…–Problem: Lots of communication across APIs»If B changes the API, A may need to make changes»Story: Large airline company spent $200 million on a new scheduling and booking system. Two teams “working together.” After two years, went to merge software. Failed! Interfaces had changed (documented, but no one noticed). Result: would cost another $200 million to fix. •Task–Person A designs, Person B writes code, Person C tests–May be difficult to find right balance, but can focus on each person’s strengths (Theory vs systems hacker)–Since Debugging is hard, Microsoft has two testers for each programmer•Most CS162 project teams are functional, but people have had success with task-based divisionsLec 9.89/29/08 Kubiatowicz CS162 ©UCB Fall 2007Communication•More people mean more communication–Changes have to be propagated to more people–Think about person writing code for most fundamental component of system: everyone depends on them!•Miscommunication is common–“Index starts at 0? I thought you said 1!”•Who makes decisions?–Individual decisions are fast but trouble–Group decisions take time–Centralized decisions require a big picture view (someone who can be the “system architect”)•Often designating someone as the system architect can be a good thing–Better not be clueless–Better have good people skills–Better let other people do workLec 9.99/29/08 Kubiatowicz CS162 ©UCB Fall 2007Coordination•More people  no one can make all meetings!–They miss decisions and associated discussion–Example from earlier class: one person missed meetings and did something group had rejected–Why do we limit groups to 5 people? »You would never be able to schedule meetings otherwise–Why do we require 4 people minimum?»You need to experience groups to get ready for real world•People have different work styles–Some people work in the morning, some


View Full Document

Berkeley COMPSCI 162 - Lecture 9 Tips for Working in a Project Team/ Cooperating Processes and Deadlock

Documents in this Course
Lecture 1

Lecture 1

12 pages

Nachos

Nachos

41 pages

Security

Security

39 pages

Load more
Download Lecture 9 Tips for Working in a Project Team/ Cooperating Processes and Deadlock
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 9 Tips for Working in a Project Team/ Cooperating Processes and Deadlock and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 9 Tips for Working in a Project Team/ Cooperating Processes and Deadlock 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?