17 Pages

Threads

Course: CIS 361, Fall 2009
School: Delaware
Rating:
 
 
 
 
 

Word Count: 759

Document Preview

processes Threads Traditional have one thread of control sequential program. Multiple threads of control are possible to get parallelism. Processes - own resources (resource grouping) - are scheduled for running (have states (Running, Ready, Blocked)) (execution) Threads The two properties of processes (resource grouping, execution) could be treated independently. Many modern OS's distinguish these and have...

Register Now

Unformatted Document Excerpt

Coursehero >> Delaware >> Delaware >> CIS 361

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
processes Threads Traditional have one thread of control sequential program. Multiple threads of control are possible to get parallelism. Processes - own resources (resource grouping) - are scheduled for running (have states (Running, Ready, Blocked)) (execution) Threads The two properties of processes (resource grouping, execution) could be treated independently. Many modern OS's distinguish these and have threads, or lightweight processes. The thread is what is scheduled for execution, with the process still owning resources. In a Multithreaded OS A process has - a virtual address space for the process image - protected access to resources (processors, other processes, files etc.) The threads take on the properties for execution. In a Multithreaded OS Each thread in a process has - an execution state (Running, Ready, Blocked) - a saved thread context when not running thread program counter - an execution stack - per-thread storage for variables - access to memory and resources of the process, shared with all the other threads of the process. (share open files) - registers Multithreading Allows OS to switch between threads. - single processor case - multiprocessor case Threads of a process share the same address space with no protection from each other. All threads in a process run as same user so this is not a prob. Usually they cooperate to work on a problem or task. Threads Create new threads with a thread_create function that takes what function to run in the thread. A thread can exit with a thread_exit call. Also have thread_wait and thread_yield calls. POSIX thread standard - -lpthread pthread_create(3C) go over sample pthreads program Why Use Threads? Multiple things can be done at once - parallel, multiprocessor, performance Programming model becomes simpler Advantages of threads over multiple cooperating processes in their shared address space and shared data. Easier to create and destroy than procs. - do not own resources Even on a single processor performance can be improved by overlapping cpu and I/O bound threads. Why Use Threads? (cont) Increased application throughput ( a process can have a # of outstanding blocking requests.) Increased application responsiveness (blocking one part of a process doesn't have to block the whole process) Improve GUI responsiveness - one thread interacts user with - others can be doing things on the cpu Thread implementations Threads can be implemented in user or kernel space (or combined in both). With threads in user space only, the kernel knows nothing about them. Process is single threaded to the kernel. OS does not need to support threads. Each process needs its own thread table. Much faster to do thread switching in user space rather than going to the kernel. Advantages of user-level threads Each process can have its own scheduling algorithm. Do not need to worry about a thread being stopped. Scale better kernel threads take up space in kernel. Problems with user-level threads Blocking system calls - blocks all the threads of the process - could work around by checking to see if call would block first (use select()) Page faults block entire process (all threads in the process) Threads must yield the cpu Many common uses use blocking system calls. Kernel level threads With kernel-level threads the kernel keeps a thread table with all the threads in system in it. When a thread blocks another can be scheduled (from same process or another one). Can better take advantage of multi-cpu system. Can run multiple threads from a process at the same time. Hybrid threads With a combined (Hybrid) approach positives from both user (good performance) and kernel (use less tricks) can be had. And minimize disadvantages. User-level threads are...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Delaware - CIS - 361
CPU SchedulingScheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource so utilize it well. May have more than 1. With multiprogramming will have many processes (threads)
Delaware - CIS - 361
Solaris Zones: Operating System Support for Consolidating Commercial WorkloadsDaniel Price and Andrew Tucker Sun Microsystems, Inc. ABSTRACTServer consolidation, which allows multiple workloads to run on the same system, has become increasingly im
Delaware - CIS - 361
DeadlocksLots of resources can only be used by one process at a time. Exclusive access is needed. Suppose process A needs R1 + R2 and B needs R1 + R2. A gets R1, B gets R2 A waits for R2, B waits for R1 A and B can't continue without second resource
Delaware - CIS - 361
Zones - ContainersServer Consolidation Run multiple workloads on system Improve utilization of resources Reduce costs Run workloads in isolation Cannot observe others Security Isolation Running apps as different user not enough - privilege escalatio
Delaware - CIS - 361
Dining PhilosophersFive philosophers sit around a table with five forks and spaghetti to eat. Philosophers think for a while and they want to eat, only spaghetti, for a while. To eat a philosopher requires two forks, one from the left and one from r
Delaware - CIS - 361
The ShellWhat does a shell do? - execute commands, programs - but how? For built in commands run some code to do the command For other commands find program executable and . run it. Other features: wildcards, pipes, redirection.ProcessesThe shell
Delaware - CIS - 361
Architecture BackgroundVon Neumann architecture - cpu = ALU + control unit - memory - devices Above connected with buses ALU carry out instruction, may have more than one execution unit Program counter memory address of next instruction to fetch.
Delaware - CIS - 361
Chapter 2 Process, Thread and Scheduling Soloris IPC1Outline Generic System V IPC Support Shared Memory System V Semaphores System V Message Queues POSIX IPC Signal Door2Generic System V IPC SupportModule TheCreationSystem V IPC
Delaware - CIS - 361
Chapter 2 Process, Thread and Scheduling - Scheduler Class and PriorityXIANG Yong xyong@tsinghua.edu.cnOutline Scheduling Class and Priority Dispatch Queues & Dispatch Tables Thread Priorities & Scheduling Turnstiles & Priority Inheritance2
Delaware - CIS - 361
Operating Systems Update: Solaris, OpenSolaris, LinuxHarry J Foxwell, PhD OS AmbassadorSun Microsystems Federal, IncSolaris 10 Introduced in Jan 05, included:> Containers: OS virtualization for isolation > > > > >consolidation/utilization Obs
Delaware - CIS - 361
Name:UDel CISC361-010 Midterm, March 24, 2005Be sure that you read each question and understand what it is asking. No calculators permitted. 1. (10 pts) True/False (circle T for True, F for False) (a) T F - The C shell (csh) is derived from the Bo
Delaware - CIS - 361
Chapter 2 Process, thread, and scheduling - Solaris Multithreaded ProcessZhao Xia zhaoxia@os.pku.edu.cnOutline Introduction to Solaris Processes Multithreaded Process Model Proc tools2The Process ModelSolarisKernel is Multi-threadedK
Delaware - CIS - 361
Name:Show your work! Partial credit will be given, but only if you show your work!. Be sure that you read each question and understand what it is asking.UDel CISC361-010 Final, December 13, 20011. 10 pts True False a T F - Segmentation is just a
Delaware - CIS - 361
ZFSNew filesystem and volume manager from Sun Open source after 5 years development First appeared in OpenSolaris, later in Solaris 10 6/06 (u2). Has been ported to FreeBSD. Also being including on Macs in the works (Leopard*) Linux FUSE port Jeff B
Delaware - CIS - 361
UDel CISC361Study Operating System principles - processes, threads - scheduling - mutual exclusion - synchronization - deadlocks - memory management - file systems - security - networking (if time allows)Operating SystemsUse of Solaris - advanced
Delaware - CIS - 361
Zones - ContainersServer Consolidation Run multiple workloads on system Improve utilization of resources Reduce costs Run workloads in isolation Cannot observe others Security Isolation Running apps as different user not enough - privilege escalatio
Delaware - CIS - 361
Architecture BackgroundVon Neumann architecture - cpu = ALU + control unit - memory - devices Above connected with buses ALU carry out instruction, may have more than one execution unit Program counter memory address of next instruction to fetch.
Delaware - CIS - 361
UDel CISC361-010 Midterm, October 24, 2001Show your work. Partial credit will be given, but only if you show your work. Be sure that you read each question and understand what it is asking.Name:1.10 ptsa b c d e f g h i j 2.True False T F
Delaware - CIS - 105
CISC 105 Fall 2005Name Circle section: 18 19 20 21Midterm 110/07/05TAGeneral Instructions DO NOT PUT YOUR SSN ON ANYTHING! DO NOT WRITE YOUR NAME ON ANY PAGE EXCEPT THIS ONE! Turn off any noise making device, especially CELL PHONES. You m
Delaware - CIS - 105
CISC105 Spring 2007 Lab11 This lab is designed to help with your project. Youll write small programs that demonstrate things you are supposed to do in the project. In general, writing small test programs that demonstrate the concepts you want to emp
Delaware - CIS - 105
CISC105 Spring 2007 Lab06 CODE! If you are having difficulty writing programs, consider programming more often. Working on C every day makes a big difference, and leaving it alone, even just for a weekend, can result in backsliding. You are learning
Delaware - CIS - 181
CISC181 Spring 2008 Lab02 If you did not use the SunRays in CISC105 or 106, then see Lab00 from this directory. Lab00 also reviews compiling and running C+ programs on Unix. This lab should be a review of programming concepts you have seen before.
Delaware - CIS - 181
Project 2, CISC181 Spring 08Domain choice due by email (see below) April 14th Testing and makefile due Thursday April 24th midnight, paper Friday in class Due Sunday April 27th midnight, paper Monday in class AssignmentPlease read the online FAQ fo
Delaware - CIS - 181
CISC181 Fall 2008 Lab01 See Lab00 if you would like to review compiling and running C+ programs on Unix. Be sure to change your disk quota as I described in an email to you last week. Remember, never delete an email from your professor or TA. Thi
Delaware - CIS - 181
Every problem starts with the same picture. Given the code, modify the picture to show what happens. Be sure to struct Node { 1) cross out pointers that go away; int data; 2) add any new pointers, structs, or data; Node * next; 3) follow the code, no
Delaware - CIS - 181
CISC181 Fall 2006 Lab02 Write a program for each of the following problems. Be sure to save every separate program. All programs must be properly commented and indented (see Assignment Standards on the class website). Ask your TA for guidance. Read
Delaware - CIS - 181
CISC181 Fall 2006 Lab09 Write a program for each of the following problems. Be sure to save every separate program. All programs must be properly commented and indented (see Assignment Standards on the class website). Ask your TA for guidance. Feel
Delaware - CIS - 181
181 Quiz 4/11/08 10 pts. Name Section TA1. Show an expression that puts a pseudo-random number into x: int x;2. The C+ language builds on C by adding three features, according to our discussion in class: inheritance, polymorphism, and 1 2 3 4 5 6
Delaware - CIS - 181
181 Quiz 5/9/08 10 pts. Name Section TA Consider the class below which has functions for addition and multiplication. class Rat{ int num; int denom; public: Rat(int n = 0, int d = 1):num(n),denom(d){} Rat operator+(const Rat& rhs); friend Rat operato
Delaware - CIS - 181
Every problem starts with the same picture. Given the code, modify the picture to show what happens. Be sure to struct Node { 1) cross out pointers that go away; int data; 2) add any new pointers, structs, or data; Node * next; 3) follow the code, no
Delaware - CIS - 181
CISC 181 Fall 2006First Midterm Learning Experience10/9/06NameLogin nameSection:TAGeneral Instructions DO NOT PUT YOUR SSN ON ANYTHING! DO NOT WRITE YOUR NAME ON ANY PAGE EXCEPT THIS ONE! Turn off any noise making device, especially
Delaware - CIS - 181
CISC181 Spring 2008 Lab01 If you did not use the SunRays in CISC105 or 106, then see Lab00 from this directory. Lab00 also reviews compiling and running C+ programs on Unix. During lab, your TA will explain how to check your disk quota, and what to
Delaware - CIS - 181
CISC181 Spring 2008 Lab03 If your SunRay sessions are behaving oddly, please check your disk usage (see lab00). If your quota is ok, then you may need to check your dot les (.login, .localenv, .cshrc, etc). This information is also available from th
Delaware - CIS - 181
CISC181 Spring 2008 Lab07 Debugging? INSERT PRINT STATEMENTS. Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Name each program lab07.n.cc
Delaware - CIS - 181
CISC181 Spring 2008 Lab06 Debugging? INSERT PRINT STATEMENTS. Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program le. Your answers will be graded. Name each program lab06.n.cc,
Delaware - CIS - 181
CISC181 Spring 2008 Lab05 Debugging? INSERT PRINT STATEMENTS. Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program le. Your answers will be graded. EVERY program you write in thi
Delaware - CIS - 181
CISC181 Spring 2008 Lab08 Debugging? INSERT PRINT STATEMENTS. Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Most of this lab will help y
Delaware - CIS - 181
CISC181 Spring 2008 Lab09 Debugging? INSERT PRINT STATEMENTS. Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program le. Your answers will be graded. Most of this lab will help you
Delaware - CIS - 181
CISC181 Spring 2008 Lab11 Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Name each program lab11.n.cc, where n is the number in the list b
Delaware - CIS - 181
CISC181 Spring 2008 Lab04 If your loop or recursion doesn't stop, then insert a print statement showing the values of your control variables before, during, and after the loop. Information is free! And it beats staring at code when you are tired. S
Delaware - CIS - 181
CISC181 Spring 2008 Lab12 Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Name each program lab12.n.cc, where n is the number in the list b
Delaware - CIS - 181
181 Leap Day Quiz 2/29/08 10 pts. Name Section TA1. Suppose you call a binary search function on an array of size 128. What is the maximum number of comparisons the code will have to make, according to our discussion in class? 2. Fill in the two bl
Delaware - CIS - 181
181 Quiz 3/28/08 10 pts. Name Section TA1. 4 Dene a struct type that will hold a student name and id number.2. 3 Declare one student and ll with data.3. 3 Declare a second student, and give it the same values as the rst without restating those
Delaware - CIS - 181
181 Quiz 5/9/08 12 pts. Name Section TAclass Flour{ private: int weight; int getWeight(){return weight;} public: Flour():weight(5){} int getWeight2(){return weight;} void say(){cout < "I am a Flour object\n";} virtual void say2(){cout < "I am a Flo
Delaware - CIS - 181
181 Quiz 3/11/08 10 pts. Name Use only the names provided! Section TAOn the four lines provided, write four single C+ statements to: 1. Declare an integer named i and initialize it to 272. Declare a pointer ip and initialize it to point to i3.
Delaware - CIS - 181
181 Quiz 2/22/08 10 pts. Name Lab Section TA1. In C+ the operators & and | both evaluate their second arguments only if it is necessary. This is called: 2. Write what this code fragment, a C+ if statement, will print, or write "error" if it won't c
Delaware - CIS - 181
181 Quiz 2/22/08 10 pts. Name Lab Section TA1. According to the Structured Programming model, there are three ways to control program flow. What are they? 2. Write what this code fragment, a C+ if statement, will print, or write "error" if it won't
Delaware - CIS - 181
CISC181 Fall 2008 Lab04 If you have not read the project document online, stop reading this and READ THE PROJECT RIGHT NOW. There are important deadlines tomorrow (Friday). Your book is an excellent resource. I nd the table of contents very good, a
Delaware - CIS - 181
CISC181 Fall 2008 Lab10 Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program le. Your answers will be graded. Dont answer questions in parentheses. Name each program lab10.n.cc, w
Delaware - CIS - 181
Project 3, CISC181 Fall 08Dec 1, 5, 6Submission dates. Submit any code you (an individual) have written as of the deadline, just to prove you are doing something.Due Sunday Dec 7th midnight, paper code copy in class MondayYou must execute the sp
Delaware - CIS - 181
CISC 181 Spring 2008Second Midterm Learning Experience4/28/08Name Section: TALogin nameGeneral Instructions DO NOT PUT YOUR SSN ON ANYTHING! DO NOT WRITE YOUR NAME ON ANY PAGE EXCEPT THIS ONE! Turn off any noise making device, especially
Delaware - CIS - 181
CISC181 Fall 2008 Lab09 Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program le. Your answers will be graded. Dont answer questions in parentheses. Name each program lab09.n.cc, w
Delaware - CIS - 181
Project 2, CISC181 Fall 08All testing code, stubs and makefile due Friday Nov 7 midnight, paper in class Due Sunday Nov 16th midnight, paper code copy in class Monday AssignmentPlease read the online FAQ for this project, which I will add to as I r
Delaware - CIS - 181
CISC181 Fall 2008 Lab06 Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Don't answer questions in parentheses. Name each program lab06.n.cc
Delaware - CIS - 181
CISC 181 Practice Fall 2008Concluding Learning Experience5/27/08NameLogin nameLecture Section:TAGeneral Instructions DO NOT PUT YOUR SSN ON ANYTHING! DO NOT WRITE YOUR NAME ON ANY PAGE EXCEPT THIS ONE! Turn off any noise making devic
Delaware - CIS - 181
CISC181 Fall 2008 Lab07 Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Don't answer questions in parentheses. Name each program lab07.n.cc
Delaware - CIS - 181
CISC181 Fall 2008 Project 3 Script Steps Names: Create a script file with each one of these actions completed. Do not print the script file, but submit it with your code on Sakai. Check each box as you do the action in your script, and submit the com
Delaware - CIS - 181
CISC 181 Spring 2008First Midterm Learning Experience3/18/08NameLogin nameSection:TAGeneral Instructions DO NOT PUT YOUR SSN ON ANYTHING! DO NOT WRITE YOUR NAME ON ANY PAGE EXCEPT THIS ONE! Turn off any noise making device, especiall
Delaware - CIS - 181
CISC181 Fall 2008 Lab08 Beta Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Don't answer questions in parentheses. Name each program lab08
Delaware - CIS - 181
CISC181 Fall 2008 Lab05 Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program le. Your answers will be graded. Dont answer questions in parentheses. Name each program lab05.n.cc, w
Delaware - CIS - 181
CISC181 Spring 2008 Lab11 Debugging? INSERT PRINT STATEMENTS. Some programs below are associated with a question. Answer the questions using C+ comments below your code in the program file. Your answers will be graded. Keep track of why we do thin