Columbia COMS W4115 - Concurrency (59 pages)

Previewing pages 1, 2, 3, 4, 27, 28, 29, 30, 56, 57, 58, 59 of 59 page document View the full content.
View Full Document

Concurrency



Previewing pages 1, 2, 3, 4, 27, 28, 29, 30, 56, 57, 58, 59 of actual document.

View the full content.
View Full Document
View Full Document

Concurrency

97 views

Other


Pages:
59
School:
Columbia University
Course:
Coms W4115 - Programming Languages and Translators
Programming Languages and Translators Documents

Unformatted text preview:

Concurrency COMS W4115 Prof Stephen A Edwards Spring 2002 Columbia University Department of Computer Science Concurrency Multiple simultaneous execution contexts Want to walk and chew gum at the same time to Capture simultaneity of system structure E g Web Servers must deal with multiple simultaneous independent requests Deal with independent physical devices The disk drive is delivering data while the network is delivering packets while the user is typing while Increase performance Split the problem into parts and solve each on a separate processor Coroutines Basic idea run two routines concurrently and let them trade control Scan Pick up where you left off Scan control transfer Parse control transfer control transfer Parse control transfer Example Lexer parser Scan control transfer Parse control transfer Coroutines char c void scan c s transfer parse c a transfer parse c e transfer parse parse char buf 10 transfer scan buf 0 c transfer scan buf 1 c transfer scan buf 2 c Implementing Coroutines Languages such as C C Java don t have direct support Some libraries provide such a mechanism Challenge Each couroutine needs a separate stack Can be faked often done Faking Coroutines in C returns 0 1 9 10 9 1 0 0 int count int i for i 0 i 10 i return i for i 10 i 0 i return i for return 0 Faking Coroutines in C returns 0 1 9 10 9 1 0 0 int count static int state 0 static int i switch state case 0 for i 0 i 10 state 1 return i case 1 for i 10 i 0 state 2 return i case 2 for state 3 return 0 case 3 program counter state use static not automatic vars i i Faking Coroutines in Java Harder because it insists on more structure class Corout int state 0 int i public int count switch state case 0 i 0 case 1 while i 10 state 1 return i i 10 case 2 while i 0 state 2 return i case 3 state 3 return 0 return 0 Cooperative Multitasking Coroutines explicitly say when to context switch and who to run next Programmer completely responsible for scheduling Alternative cooperative multitasking



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

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