Lab07

Lab07 - KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS Information and Computer Science Department ICS 431 Operating Systems Lab # 7 Threads Creation and Execution Objective: This lab examines aspects of threads and multiprocessing (and multithreading). The primary objective of this lab is to implement the Thread Management Functions: * Creating Threads * Terminating Thread Execution * Passing Arguments To Threads * Thread Identifiers * Joining Threads * Detaching / Undetaching Threads What is thread? A thread is a semi-process, that has its own stack, and executes a given piece of code. Unlike a real process, the thread normally shares its memory with other threads (where as for processes we usually have a different memory area for each one of them). A Thread Group is a set of threads all executing inside the same process. They all share the same memory, and thus can access the same global variables, same heap memory, same set of file descriptors, etc. All these threads execute in parallel (i.e. using time slices, or if the system has several processors, then really in parallel). What are pthreads? * Historically, hardware vendors have implemented their own proprietary versions of threads. These implementations differed substantially from each other making it difficult for programmers to develop portable threaded applications. * In order to take full advantage of the capabilities provided by threads, a standardized programming interface was required. For UNIX systems, this interface has been specified by the IEEE POSIX 1003.1c standard (1995). Implementations which adhere to this standard are referred to as POSIX threads, or Pthreads. Most hardware vendors now offer Pthreads in addition to their proprietary API's. * Pthreads are defined as a set of C language programming types and procedure calls . Vendors usually provide a Pthreads implementation in the form of a header/include file and a library, which you link with your program. Why pthreads? The primary motivation for using Pthreads is to realize potential program performance gains.
Background image of page 1

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

View Full DocumentRight Arrow Icon
± When compared to the cost of creating and managing a process, a thread can be created with much less operating system overhead. Managing threads requires fewer system resources than managing processes. ± All threads within a process share the same address space. Inter-thread communication is more efficient and in many cases, easier to use than inter-process communication. ± Threaded applications offer potential performance gains and practical advantages over non-threaded applications in several other ways: 9 Overlapping CPU work with I/O: For example, a program may have sections where it is performing a long I/O operation. While one thread is waiting for an I/O system call to complete, other threads can perform CPU intensive work. 9
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/02/2011 for the course CS 7103 taught by Professor Kannan during the Fall '11 term at LSU.

Page1 / 14

Lab07 - KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS...

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

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