Lab4-thread

Lab4-thread - Lab 4 Working with Threads in Linux/Unix...

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

View Full Document Right Arrow Icon
Lab 4 Working with Threads in Linux/Unix
Image of page 1

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

View Full Document Right Arrow Icon
Before You Start… Login to Linux Boot the PC, and select the option: SLIM/SWIM Choose 5 Ubuntu 10.04 Login the system using CS account info Download lab4.tgz from course webpage to Desktop Then, in a terminal cd ~/Desktop tar xzvf lab4.tgz cd lab4 make When you see Try these command(s) in your terminal TRY!
Image of page 2
What is a Thread? Independent stream of execution that can be scheduled to run by operating system Consider a program contains a number of procedures Let’s imagine all of these procedures being able to be scheduled to run simultaneously and/or independently by the operating system That would describe as a “multi - threaded” program. Source : POSIX Threads Programming by Blaise Barney, Lawrence Livermore National Laboratory
Image of page 3

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

View Full Document Right Arrow Icon
What is a Thread? A thread Exists within a process and uses the process resources Has its own independent flow of control as long as its parent process exists Duplicates only the essential resources it needs to be independently schedulable May share the process resources with other threads that act equally independently (and dependently) Dies if the parent process dies Source : POSIX Threads Programming by Blaise Barney, Lawrence Livermore National Laboratory
Image of page 4
Thread Programming Models Two ways to create multiple threads in a program Explicit threading e.g., Pthread, Window thread, Java thread, etc. Programmers need to create, manage, and terminate the threads explicitly (using function calls) Implicit threading e.g., OpenMP, Intel TBB, etc. Programmers identify the workload or tasks that could be run concurrently; then instruct the computer to create multiple concurrent threads to execute those tasks/workload
Image of page 5

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

View Full Document Right Arrow Icon
Why use POSIX threads?
Image of page 6
Image of page 7
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