1 / 7

Chapter 26 Concurrency & Thread

Chapter 26 Concurrency & Thread. Chien -Chung Shen CIS, UD cshen@cis.udel.edu. Introduction. Abstractions p rocess - virtualize one CPU for multiprogramming a ddress space – virtual memory

aurek
Download Presentation

Chapter 26 Concurrency & Thread

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 26Concurrency & Thread Chien-Chung Shen CIS, UD cshen@cis.udel.edu

  2. Introduction • Abstractions • process - virtualize one CPU for multiprogramming • address space – virtual memory • Multi-threaded program has more than one point of execution - multiple PCs, each of which is being fetched and executed from • multiple “light-weight” processes sharing the same address space • context switching between threads

  3. Stacks Single-threaded 2-threaded

  4. Thread Creation • Figure 26.2 • Execution traces: Tables 26.1-3

  5. Shared Data • Figure 26.3 - two threads update a global shared variable • Non-deterministic results due to uncontrolled Scheduling • prompt> objdump -d main// Linux • counter = counter + 1; • mov 0x8049a1c, %eax add $0x1, %eax mov %eax, 0x8049a1c • Table 26.4

  6. Race Condition • Results depend on the timing execution of the code- with some bad luck (i.e., context switches that occur at untimely points in the execution), we get the wrong (or different) result • Because multiple threads executing this code can result in a race condition, we call this code a critical section • A critical section is a piece of code that accesses a shared variable (or more generally, a shared resource) and must not be concurrently executed by more than one thread • Mutual exclusion - property guarantees that if one thread is executing within the critical section, the others will be prevented from doing so

  7. Atomicity • One way to solve race condition to have more powerful instructions that, in a single step, did exactly whatever we needed done and thus removed the possibility of an untimely interrupt • Synchronization primitives on top of hardware • Every kernel data structure has to be carefully accessed, with the proper synchronization primitives, to work correctly

More Related