Lab4-thread

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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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!
Background 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
Background image of page 3

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

View Full DocumentRight 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
Background 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
Why use POSIX threads? Each OS had it’s own thread library and style That makes writing multithreaded programs difficult because: you had to learn a new API with each new OS you had to modify your code to port to a new OS POSIX (IEEE 1003.1c-1995) provided a standard known as Pthreads (POSIX threads)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

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

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online