threads-04 - Threads Announcements Cooperating Processes...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Threads
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Announcements
Image of page 2
Cooperating Processes Last time we discussed how processes can be independent or work cooperatively Cooperating processes can be used: to gain speedup by overlapping activities or working in parallel to better structure an application as set of cooperating processes to share information between jobs Sometimes processes are structured as a pipeline each produces work for the next stage that consumes it
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Consider the following code fragment on a dual core CPU: for(k = 0; k < n; k++) a[k] = b[k] * c[k] + d[k] * e[k]; Instead: CreateProcess(fn, 0, n/2); CreateProcess(fn, n/2, n); fn(l, m) for(k = l; k < m; k++) a[k] = b[k] * c[k] + d[k] * e[k]; Case for Parallelism
Image of page 4
Case for Parallelism Consider a web server: Get network message from socket Get URL data from disk Compose response Write compose. Server connections are fast, but client connections may not be (grandma’s modem connection) Takes server a loooong time to feed the response to grandma While it’s doing that it can’t service any more requests
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Parallel Programs To build parallel programs, such as: Parallel execution on a multiprocessor Web server to handle multiple simultaneous web requests We will need to: Create several processes that can execute in parallel Cause each to map to the same address space because they’re part of the same computation Give each its starting address and initial parameters The OS will then schedule these processes in parallel
Image of page 6
Process Overheads A full process includes numerous things: an address space (defining all the code and data pages) OS resources and accounting information a “thread of control”, defines where the process is currently executing That is the PC and registers Creating a new process is costly all of the structures (e.g., page tables) that must be allocated Context switching is costly Implict and explicit costs as we talked about
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Need something more lightweight What’s similar in these processes?
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern