UW CSE 303 - Lecture Notes (13 pages)

Previewing pages 1, 2, 3, 4 of 13 page document View the full content.
View Full Document

Lecture Notes



Previewing pages 1, 2, 3, 4 of actual document.

View the full content.
View Full Document
View Full Document

Lecture Notes

73 views

Lecture Notes


Pages:
13
School:
University of Washington
Course:
Cse 303 - Concepts and Tools for Software Development
Concepts and Tools for Software Development Documents

Unformatted text preview:

CSE 303 Concepts and Tools for Software Development Hal Perkins Autumn 2008 Lecture 22 Shared Memory Concurrency CSE303 Autumn 2008 Lecture 22 1 Concurrency Computation where multiple things happen at the same time is inherently more complicated than sequential computation Entirely new kinds of bugs and obligations Two forms of concurrency time slicing only one computation at a time but pre empt to provide responsiveness or mask I O latency true parallelism more than one CPU e g the lab machines have two the attu machines have 4 your laptop has No problem unless the different computations need to communicate or use the same resources CSE303 Autumn 2008 Lecture 22 2 Example Processes The O S runs multiple processes at once Why Convenience efficient use of resources performance No problem keep their address spaces separate But they do communicate share via files and pipes Things can go wrong e g a race condition echo hi someFile foo cat someFile assume foo holds the string hi The O S provides synchronization mechanisms to avoid this See CSE451 we will focus on intraprocess concurrency CSE303 Autumn 2008 Lecture 22 3 The Old Story We said a running Java or C program had code a heap global variables a stack and what is executing right now in assembly a program counter C Java support parallelism similarly other languages can be different One pile of code global variables and heap Multiple stack program counter s called threads Threads can be pre empted whenever by a scheduler Threads can communicate or mess each other up via shared memory Various synchronization mechanisms control what thread interleavings are possible Do not do your thing until I am done with my thing CSE303 Autumn 2008 Lecture 22 4 Basics C The POSIX Threads pthreads library include pthread h Link with lpthread pthread create takes a function pointer and an argument for it runs it as a separate thread Many types functions and macros for threads locks etc Java Built into the language Subclass java lang



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Lecture Notes 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 Notes 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?