tailieunhanh - Lecture Programming languages (2/e): Chapter 17 - Tucker, Noonan
Chapter 17 - Concurrent programming. This chapter illustrates each of these scenarios, along with the coordination and data shming strategies that underlie their effective implementation. To provide a focus for this discussion, our examples favor Java as the language of illustration. Concurrency features in several other languages are summalized at the end of the chapter. | Programming Languages 2nd edition Tucker and Noonan Chapter 17 Concurrent Programming Two roads diverged in a yellow wood, And sorry I could not travel both . Robert Frost, The Road Not Taken Contents Concurrency Concepts Synchronization Strategies Synchronization in Java Interprocess Communication Concurrency in Other Languages Concurrency occurs at many levels More realistic Can be more efficient Carries unique, fundamental complexities Traditionally studied in the context of operating systems Example: client-server application such as web browsing Concurrency Concepts Example: web browser rendering a page Page is a shared resource Thread for each image load Thread for text rendering Cannot all write to page simultaneously Thread for user input; ., Stop button Multiprogramming: several programs loaded into memory and executed in an interleaved manner Scheduler: switches from one program or thread to another Time-sharing: allow multiple users to communicate with a computer simultaneously Process: an execution context, including registers, activation stack, next instruction to be executed, etc. Defn: A concurrent program is a program designed to have two or more execution contexts. Such a program is said to be multithreaded, since more than one execution context can be active simultaneously. Parallel program: 2 or more threads simultaneously active. Distributed program: designed so that different pieces are on computers connected by a network. Concurrency: a program with multiple, active threads. Single threaded: all earlier programs. States of a thread: Created: but not yet ready to run Runnable: ready to run; awaiting a processor Running: executing Blocked: waiting on some resource Terminated: stopped States of a Thread Figure Inter-thread communication needs to occur: Thread requires exclusive access to some resource Thread needs to exchange data with another thread Can communicate via: Shared variables Message passing . | Programming Languages 2nd edition Tucker and Noonan Chapter 17 Concurrent Programming Two roads diverged in a yellow wood, And sorry I could not travel both . Robert Frost, The Road Not Taken Contents Concurrency Concepts Synchronization Strategies Synchronization in Java Interprocess Communication Concurrency in Other Languages Concurrency occurs at many levels More realistic Can be more efficient Carries unique, fundamental complexities Traditionally studied in the context of operating systems Example: client-server application such as web browsing Concurrency Concepts Example: web browser rendering a page Page is a shared resource Thread for each image load Thread for text rendering Cannot all write to page simultaneously Thread for user input; ., Stop button Multiprogramming: several programs loaded into memory and executed in an interleaved manner Scheduler: switches from one program or thread to another Time-sharing: allow multiple users to .
đang nạp các trang xem trước