Class 305 Focus On Threads: An Introduction Michel de Champlain ABSTRACT

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Class 305 Focus On Threads: An Introduction Michel de Champlain ABSTRACT"

Transcription

1 Class 305 Focus On Threads: An Introduction Michel de Champlain ABSTRACT Threads are now supported by many new object-oriented languages. Java provides language-level support for multi-threading, resulting in a more powerful approach to programming. By using threads, programmers can benefit of a better real-time behavior and response. This class introduces the concepts and the foundations of multithreaded programming, covers the basics in using Java threads, and finally presents several types of synchronization between threads. OBJECTIVES What you will learn from this class: advantages and issues of using threads good understanding of how threads work presents some of the major features of Java threads covers basic synchronization methods to control multiple Java threads CONTENTS Topics covered are: Background on Threads Using Java Threads Scheduling Threads Synchronizing Threads Synchronization Mechanisms INTRODUCTION The concept of multithreaded programming has been used in universities and R&D labs since the mid-70s. Languages supporting tasks (like Ada) and co-routines (like Concurrent Pascal and Modula-2) were mapping or accessing threads. This concept has emerged into industry as an accepted programming paradigm in the early-90s, but no major commercial operating systems offered threads library. After five years, all of them (Windows 95 and NT, Solaris, and OS/2 to name a few) has one. The next sections of this chapter will give a basic understanding of threads---what they are, how they work, and why they are useful. They will also clarify the terminology associated with the subject of multitasking.

2 One of the most complex operating system activities is its allocation of the processor to multiple programs. This chapter concentrates on the concepts of active execution environment. We look at the details of terminology associated with the subject of multitasking and the Java multithreading model. BACKGROUND ON THREADS A multitasking operating system is a complex programming environment that can run two or more programs concurrently---programs share the processor, so they run simultaneously (also called pseudo-parallelism). Several modern operating systems, such as Unix and Windows 95, support two forms of multitasking: process-based and thread-based. Processes vs. Threads A process is a single-thread (active unit) which executes a program without parallelism (quasi-parallellism on a uniprocessor) that can be blocked (state, regs, etc.). Found in the 1980's, the UNIX notion of a process: associates just one processing activity with each process is an expensive resource to create and manage makes sharing between related activities awkward The solution: generalize the notion of process so that it can be associated with multiple activities In the early-90s, in order to improve the performance of processes, threads were introduced. A thread is a dispatchable unit of executable code within a process. The name comes from the concept of a thread of execution. All processes have at least one thread, so two or more parts of a single program can be executed concurrently. We will see later on in this class that thread-based multitasking increases the need of coordination and synchronization between threads and processes. Many older operating systems allow only one thread per process called heavyweight process. A thread is a lightweight process. An old program communicated among its processes through traditional interprocess communication facilities, such as pipes or sockets. A process can have: multiple threads of control, they: are lightweight processes share the same address space (global variables)

3 may share (reentrant) code have no protection between them net result: higher throughput and better performance can share buffers more than one blocking In summary, multithreaded programming is the division of a program into multiple threads that execute concurrently. Each program is a single threaded process that has: code (sequence of instructions) registers (such a program counter that points to the current instruction and a stack pointer that designates the current active frame on the stack) (global) data stack (containing local data, parameters and return addresses) heap (for dynamic allocation) Several threads can: share all resources accessible within them more efficiently (+) maximize the degree of concurrent execution (+) be cheaper to create and manage (context switch) than processes (+) but, within a process there is no protection (-) Utility of threads: allow computation to be overlapped with I/O if multiprocessor, overlapped with other computation Threads vs multiple processes: An example Is multiple single-threaded process model vs multi-threaded process model have the same throughput? A classic example is a server program, which can maintain one thread for each client connection. To fully understand the difference, let us consider a server with threads as an example:

4 N threads receive messages from a port assume each request takes (on average) 2ms of processing 8ms of I/O delay when the server reads from device Maximum server throughput (MST) = client requests/sec For a single thread: average request = 10ms (2+8), so MST = 100 (1000/10) client requests/sec For two threads (one can be scheduled when another becomes blocked for I/O) if all disk requests are serialized: average request = 8ms, so MST = 125 (1000/8) client requests/sec If disk block caching is introduced and 75% hit rate (page found 75% of the time) is achieved: average request = 2ms (0.75x x8), so MST = 500 (1000/2) client requests/sec If average processor time for a request increased to 2.5ms as a result of caching: average request = 2.5ms, so MST = 400 (1000/2.5) client requests/sec Throughput can be increased by using: shared memory multiprocessor multi-threaded process maps naturally onto it Threads can be independently scheduled to the different processors. Two threads process requests in parallel: bounded only by the I/O = 2ms (0.75x x8) not bounded anymore the processing time for caching can process 500 (1000/2) requests/sec Threads can be useful for clients as well as servers. A client process with two threads: calls block the caller no need to wait first thread is able to continue computing

5 Comparison of processes and threads: a rough guide creation (11ms vs 1ms)---factor of 10 context switch (2ms vs 0.05ms)factor of 40 Thread execution Threads are like processes, you cannot make any assumptions about: the relative start or finish time of them the sequence in which they execute Each thread: has its own identifier (no, ptr, handle, etc.) has its scheduling policy and priority must be reentrant (most modern compilers generate reentrant code by default) A thread is in one of the following states: RUNNING, READY or BLOCKED. Threads synchronization Threads programming is concurrent programming. It refers to the same concurrent programming concepts as: race condition critical section condition variable semaphore etc. Programming a multi-threaded process requires great care, because of scope of variables and thread coordination and cooperation. Each thread has a private stack, local variables in procedures are always private to the thread executing the procedure (still not protected against accesses of other threads), and no private heaps or private copies of static variables. Exemple: attempt to use the C standard I/O library with a threads package library uses a single buffer for each I/O stream

6 race condition problem: if more than one thread attempted to use the same output stream to a terminal (each read the value of this pointer and update it independently and inconsistently) potential solutions: I/O library either has to be modified buffer must be dynamically allocated for each thread and used exclusively by it Thread scheduling Two main approaches: preemptive and non-preemptive (co-routine or cooperative). A thread with a non-preemptive scheduling runs until it makes an explicit call (reschedule, relinquish or yield) that causes it to be rescheduled and another thread to be run. Both scheduling approaches have been implemented for many thread packages, the programmer chooses one or the other by linking in different libraries. The main advantage of non-preemptive scheduling: any section of code that does not contain a call that might cause a rescheduling is automatically a critical section (race conditions are thus conveniently avoided) The main disadvantage of non-preemptive scheduling: (1) cannot take advantage of a multiprocessor (threads run exclusively) (2) unsuited to real-time applications (events associated with absolute times or deadlines cannot be processed) The main disadvantage if threads have all the same priority: certain events, which are more urgent than others cannot be served. Static priorities by themselves are not sufficient for real-time processing. For example, in multimedia applications: data (voice and video) have real-time requirements for both communication and processing Thread scheduling requirements are likely to be particular to each real-time application domain. It is desirable for applications to implement their own scheduling policies. Java is not flexible enough right now. We are porting a nanokernel called OpenKernel that will offer such flexibility and run on top of Java. OpenKernel will be public domain and available soon. We are looking for beta testers before our first public release, if you are interested, contact me at Thread implementation Some conventional kernels have only a single-threaded process abstraction, but multi-threaded processes are implemented in a library of procedures (linked with application programs).

7 Advantages of user-level and kernel-level scheduling: application-specific considerations user-level code can provide scheduling hints two-level scheduling scheme (more flexible) user-level scheduler within a process kernel-level scheduler retains control over the allocation of processor time between processes Why Java threads? Why do Java applications need to use threads? able to perform multiple tasks at the same time an easy way to implement asynchronous behavior in applications Synchronous actions can be performed by a thread while other threads are executing different tasks. Java threads could be considered a limited threads package when compared to POSIX (P1003.4a). But, it has a big advantage: Its simplicity. All of Java libraries are thread safe. A library is thread safe if the functions or methods in that library are safe to be called from multiple threads at the same time. A function can be called from multiple threads at the same time. The use of static data: All the threads try to change the static value at the same time, unexpected results may be produced. Not all libraries used by today's programs are thread safe. The use of locks: By using a simplistic locking mechanism that is controlled by the Java run-time. USING JAVA THREADS As we have mentionned before, Java provides a simple way of creating, controlling, and coordinating threads. Java is a multithreaded language, which means there can be many threads running at the same time. Java threads can be started, stopped, suspended, and prioritized. Threads are preemptive, so a higher priority thread can interrupt a lower priority thread.

8 Creating and Starting a Thread There are two ways to create a thread in Java: by implementing the Runnable interface or by inheriting from the Thread class. The Runnable Interface The Thread class has many methods of managing the execution of a thread object. By using the Runnable interface, you simplify (and restrict) the implementation of your thread to the run() method. Here is the definition of the Runnable interface: public interface Runnable { public abstract void run(); The above interface allows you to implement a class without extending it from the Thread class and still be able to make instances that will run as threads. How to define a class that is runnable? You have to create a class T that implements the Runnable interface (line 1). Then, you need to override the run () method (line 2): 1 class T implements Runnable { 2 public void run() { 3 // For those of you who are using threads or tasks in C, you are normally expressing where the thread must run by passing a pointer to a function. Since there are no pointers to methods in Java, we are using the interface to create a thread reference that tells the thread where to start running---that is the run() method. Because an interface forces a subclass T to implements its method(s). Each instance of that subclass T will execute a run() method holding the body of the thread's code. Creating Threads from a class T In this case, the creation of threads is done in two steps. Firstly, we need to make an instance t of the above class T. Secondly, we create a thread object---an instance of the

9 Thread class--- by passing t as reference to our runnable object that becomes a new thread. T t = new T(); Thread thread = new Thread(t); Starting Threads To start the thread we must execute its start() method: thread.start(); The thread then wakes up and executes the run() method of its t object. The start method can be called only once in the lifetime of a Thread. Once a thread starts, it continues running until the run() method ends, or we call the thread's stop() method to terminate the thread. A new thread remains idle (not ready) until we execute its start() method. How to use the class construction to simplify this creation? An object can create and start its own thread by using its constructor to perform these actions: class T implements Runnable { public T() { thread = new Thread( this ); thread.start(); public void run() { //... private Thread thread; Here, the argument we pass to the T constructor is the current object instance this. The Thread Class The second way to create a thread is to extend a class that is already runnable. The Thread class itself implements the Runnable interface meaning that it has already its own run() method we can override: class T implements Thread { public void run() { dosomething();

10 Now our T class is a kind of Thread. In this case, you don't need to implement a default constructor (line 2) since the java.lang.thread class has already done the work for you: making itself the default current object 'this' (line 3): 1 class Thread implements Runnable { 2 public Thread() { 3 thread = new Thread( this ); 4 thread.start(); 5 6 public void run() { 7 // empty body of code 8 7 By default, the Thread executes its own run() method that is empty (lines 6-8) when the start() method is invoked (line 4). That's why our subclass T must override the run() method in the Thread class to dosomething(). Finally, we create an instance of T and execute its start() method: T t = new T(); t.start(); Again to simplify, we can have the T object start itself when its created: class T implements Thread { T() { start(); public void run() { dosomething(); Making the creation and execution in one line: T t = new T(); Controlling Threads We can control a thread's execution using three other methods: stop(), suspend(), and resume(). These methods take no argument because they operate on the current object.

11 Using the stop method The stop() method complements start(); it destroys the thread. start() and stop() can be called only once in the life of a thread. Stopping a thread. The stop () method. Once a thread has been stopped it cannot be resumed or restarted. Nothing happens after the start () method is called again on the thread. Killing the thread, it can never come to life again. Using the suspend method Once a thread has been created and is started it can be suspend using the suspend() method. Suspending a thread does not destroy it, in fact, it is a good alternative to pause its execution without doing a stop/create/start sequence (mainly, because this sequence is very inefficient if it needs to be done too often). Using the resume method Once a thread has been suspended it can be resumed by the resume() method. Resuming a thread puts it back on the ready queue. Using the sleep method Sometimes you need to put a thread to sleep for some period of time. The Thread.sleep() is a static method of the Thread class that causes the currently executing thread to delay for a specified number of milliseconds. class T implements Thread { public void run() { while ( true ) { dosomething(); Thread.sleep(1000); // or sleep(1000); When a thread is asleep, it doesn't consume CPU time or compete with other threads for processing. Exercise Lifetime of Threads A thread continues to execute until one of the following things happens:

12 it returns from its target run() method it's interrupted by an uncaught exception its stop() method is called SCHEDULING THREADS Scheduling is related to a specific decision of choosing the 'next ready' thread and making it 'running'. The thread state and priority are influencing how threads will be scheduled. Thread State In Java, a thread exists in many different states. By invoking a Thread class method calls, you may cause a state change. Here are the three main states: idle (or born)---when a new thread is created, i.e. the object exists but it has not started yet runnable (or ready)---when a new thread is started, i.e. the object is in the ready queue available to be eventually scheduled but it is not running yet non-runnable (or blocked)---when a thread invokes one of these methods, it can not be scheduled for execution: sleep()---back to runnable state when the sleep interval expires suspend()---back to runnable state when the resume() method is invoked wait()---back to runnable state when one of the nofify methods is invoked (this will be explained in the synchronization section) a blocking method (for i/o, such as read/write) ---back to runnable state when the i/o is completed dead (or terminated)---when a thread reaches the end of the run() or the stop() method is called How to Get a Threads State? Unfortunately, Java is not well equipped to let us know the precise state of a thread. Thread class has only one method, called isalive(), that returns a boolean to say if the thread is running or not. There is no way to determine if a thread is runnable, non-runnable, dead or not borned yet. Thread Priority In Java, we can use a priority to determine what threads will be scheduled

13 for execution. A higher priority thread always run before a lower priority one. A thread is preemptable---a lower priority thread is replaced by a higher priority one. Java supports ten different priority levels: from the lowest Thread.MIN_PRIORITY (1) to the highest priority Thread.MAX_PRIORITY (10). If two or more threads have the same priority, they will be scheduled in a round-robin fashion. Time Slicing Java threads can also be time sliced but that feature is operating system dependent. One way to cause a thread to give up its time is to invoke the yield() methods explicitly. This will allow another equal priority or higher priority thread to run. SYNCHRONIZING THREADS Synchronization is critical in most multithreaded programs because threads are sharing resources. Requirements for thread interaction Why and how threads interact: need to cooperate to carry out some task requirement for synchronization may compete for exclusive use of services or resources (simultaneous requests) requirement for mutual exclusion Race Conditions To illustrate race condition, the following two threads are executed with unpredictable relative speeds. Race conditions occur when simultaneous threads share data or resources, like the variable count: Thread Observer while (true) observeanevent; count = count + 1; Thread Reporter while (true) print count; count = 0;

14 A sample execution (initially, count was set to zero): Observer Reporter Output observeanevent; print count 0 count = count + 1; count = 0; (lost one!) observeanevent; count = count + 1; print count 1 observeanevent; count = count + 1; count = 0; (lost one!) print count 0 SYNCHRONIZATION MECHANISMS How do we prevent race conditions, if the final application depends on the order of execution? Even if the probability of race conditions is very small, it could happen... Solution: an atomic action that is a sequence of one or more statements that appears to be indivisible; i.e. no other thread can see an intermediate state of this action. Critical Sections and Mutual Exclusion Critical section: part of program accessing a shared resource. Mutual exclusion: one process at a time. Race conditions can be avoided by enforcing mutual exclusion in critical sections. Choice of mutual exclusion primitives is important. Good ones: enforce mutual exclusion make no assumptions on number or speed of CPUs ensure progress In the following section we will introduce two ways (software and hardware) to achieves mutual exclusion. At first, we will see some software proposals and finally examine how modern solutions are supported by the hardware in practice. Monitors Java threads use monitors to control access to critical sections in

15 application code. Think of monitors as a type of mutex lock. Solves this problem by controlling the locking and unlocking of the monitor for you. Every Java object class has an associated monitor. Whenever an object is instantiated, Java adds a unique monitor to that object and its associated class. The monitor is allocated and brought to life only when it is used. A thread can acquire a monitor by entering a method that has been defined as synchronized. When one thread holds the monitor, another thread that tries to acquire the monitor will be blocked and forced to wait until it is released. Condition Variables Java does support the direct use of condition variables. Same effect of using condition variables can be achieved with the wait() and notify(). The wait(), notify(), and notifyall() methods can only be used from within synchronized methods. The wait() method blocks and waits for a certain condition to be satisfied. When the thread is signaled, it reacquires the monitor and continues execution after the wait(). The notify() method is similar to a condition_signal() variable. notify() signals a waiting thread to wake from a wait() method. NotifyAll() wakes all the threads in the object that are blocked in a wait() call. This class has to many examples that illustrate the features being presented. But since it is not possible to integrate all examples in this paper, the full code listings will be given as a handout during the class. REFERENCES Birrel, A.D., An Introduction to Programming with Threads, Digital SRC#35, Palo Alto, Excellent reference on thread programming. J. Boykin et al, Programming Under Mach, Addison-Wesley, Digital Equipment Corporation, DECthreads: Guide to DECthreads, Maynard, Mass, March Bill Lewis, Daniel J. Berg, Threads Primer: A Guide to Multithreaded Programming Prentice-Hall, Java Development Kit Documentation, JDK1.1.1, Sun Microsystems, 1997.

There are two distinct types of Multitasking i.e. Processor-Based and Thread-Based multitasking.

There are two distinct types of Multitasking i.e. Processor-Based and Thread-Based multitasking. Multithreading Multithreading is a conceptual programming concept where a program (process) is divided into two or more subprograms (process), which can be implemented at the same time in parallel. A multithreaded

More information

Introduction to Java A First Look

Introduction to Java A First Look Introduction to Java A First Look Java is a second or third generation object language Integrates many of best features Smalltalk C++ Like Smalltalk Everything is an object Interpreted or just in time

More information

Chapter 6, The Operating System Machine Level

Chapter 6, The Operating System Machine Level Chapter 6, The Operating System Machine Level 6.1 Virtual Memory 6.2 Virtual I/O Instructions 6.3 Virtual Instructions For Parallel Processing 6.4 Example Operating Systems 6.5 Summary Virtual Memory General

More information

Lecture 2 Introduction to Concurrency

Lecture 2 Introduction to Concurrency CMSC 433 Spring 2014 Section 0101 Rance Cleaveland Lecture 2 Introduction to Concurrency 1/29/2014 2012-14 University of Maryland Running a Sequential Program Executable Machine instructions to be performed

More information

Introduction to Multithreading in Java. - Alessio Bechini - PCB TCB TCB TCB. Runtime Support Library for Threads (TCB manager)

Introduction to Multithreading in Java. - Alessio Bechini - PCB TCB TCB TCB. Runtime Support Library for Threads (TCB manager) 2 Introduction to Multithreading in Java - Alessio Bechini - Multitasking and Multithreading PCB Single PCB TCB TCB TCB Multiple s Runtime Support Library for s (TCB manager) Operating System (PCB Manager)

More information

CS 571 Operating Systems. CPU Scheduling. Angelos Stavrou, George Mason University

CS 571 Operating Systems. CPU Scheduling. Angelos Stavrou, George Mason University CS 571 Operating Systems CPU Scheduling Angelos Stavrou, George Mason University CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms First-Come-First-Served Shortest-Job-First, Shortest-remaining-Time-First

More information

Lecture 2 Introduction to Concurrency

Lecture 2 Introduction to Concurrency CMSC 433 Fall 2016 Section 0101 Rance Cleaveland Lecture 2 Introduction to Concurrency 9/1/2016 2012-16 University of Maryland Running a Sequential Program Executable Machine instructions to be performed

More information

What is a Thread? Similar to a process Separate thread of execution Each thread has a separate stack, program counter, and run state

What is a Thread? Similar to a process Separate thread of execution Each thread has a separate stack, program counter, and run state What is a Thread? Similar to a process Separate thread of execution Each thread has a separate stack, program counter, and run state Steven M. Bellovin February 1, 2006 1 Differences Between Processes

More information

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Processes and Non-Preemptive Scheduling. Otto J. Anshus Processes and Non-Preemptive Scheduling Otto J. Anshus 1 Concurrency and Process Challenge: Physical reality is Concurrent Smart to do concurrent software instead of sequential? At least we want to have

More information

Multithreading in Java

Multithreading in Java Multithreading in Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park Problem Multiple tasks for computer Draw & display images on screen Check keyboard

More information

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts

More information

III. Process Scheduling

III. Process Scheduling Intended Schedule III. Process Scheduling Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment

More information

III. Process Scheduling

III. Process Scheduling III. Process Scheduling 1 Intended Schedule Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment

More information

CPU Scheduling! Basic Concepts! Scheduling Criteria! Scheduling Algorithms!

CPU Scheduling! Basic Concepts! Scheduling Criteria! Scheduling Algorithms! CPU Scheduling! Basic Concepts! Scheduling Criteria! Scheduling Algorithms! First-Come-First-Served! Shortest-Job-First, Shortest-remaining-Time-First! Priority Scheduling! Round Robin! Multi-level Queue!

More information

Real Time Programming: Concepts

Real Time Programming: Concepts Real Time Programming: Concepts Radek Pelánek Plan at first we will study basic concepts related to real time programming then we will have a look at specific programming languages and study how they realize

More information

CSC System Development with Java Threads

CSC System Development with Java Threads CSC 308 2.0 System Development with Java Threads Department of Statistics and Computer Science 1 Multitasking and Multithreading Multitasking: Computer's ability to perform multiple jobs concurrently More

More information

Lecture 4: Synchronization Primitives

Lecture 4: Synchronization Primitives Lecture 4: Synchronization Primitives CS178: Programming Parallel and Distributed Systems February 5, 2001 Steven P. Reiss I. Overview A. Topics covered last time 1. Different types of synchronization

More information

Introduction to Operating Systems. CS 499: Special Topics in Cyber Security S. Sean Monemi

Introduction to Operating Systems. CS 499: Special Topics in Cyber Security S. Sean Monemi Introduction to Operating Systems CS 499: Special Topics in Cyber Security S. Sean Monemi 1 Overview Operating Systems Definition Processes and Threads Program Control Blocks Process Scheduling and Interrupts

More information

Threads (Ch.4) ! Many software packages are multi-threaded. ! A thread is sometimes called a lightweight process

Threads (Ch.4) ! Many software packages are multi-threaded. ! A thread is sometimes called a lightweight process Threads (Ch.4)! Many software packages are multi-threaded l Web browser: one thread display images, another thread retrieves data from the network l Word processor: threads for displaying graphics, reading

More information

Mutual Exclusion using Monitors

Mutual Exclusion using Monitors Mutual Exclusion using Monitors Some programming languages, such as Concurrent Pascal, Modula-2 and Java provide mutual exclusion facilities called monitors. They are similar to modules in languages that

More information

Embedded Systems. Real Time Systems (Part I) Real Time Operating System (RTOS) Definition and Characteristics

Embedded Systems. Real Time Systems (Part I) Real Time Operating System (RTOS) Definition and Characteristics Embedded Systems Real Time Systems (Part I) Dr. Jeff Jackson Lecture 12-1 Real Time Operating System (RTOS) Definition and Characteristics A real-time operating system (RTOS) is an operating system (OS)

More information

Structuring the Control

Structuring the Control Structuring the Control Hints on control-in-the-small Essential elements of control-in-the-large (parallel execution) Ghezzi&Jazayeri: Ch 4 1 Control in-the-small From if-then-else, while, case, for,...

More information

Chapter 2: OS Overview

Chapter 2: OS Overview Chapter 2: OS Overview CmSc 335 Operating Systems 1. Operating system objectives and functions Operating systems control and support the usage of computer systems. a. usage users of a computer system:

More information

CONCURRENT PROGRAMMING WITH THREADS R I C K M E R C E R, R I C K S N O D G R A S S, I V A N V A S Q U E Z W I T H H E L P F R O M J O S H B L O C K

CONCURRENT PROGRAMMING WITH THREADS R I C K M E R C E R, R I C K S N O D G R A S S, I V A N V A S Q U E Z W I T H H E L P F R O M J O S H B L O C K CONCURRENT PROGRAMMING WITH THREADS R I C K M E R C E R, R I C K S N O D G R A S S, I V A N V A S Q U E Z W I T H H E L P F R O M J O S H B L O C K OUTLINE Basic concepts Processes Threads Java: Thread

More information

First-class User Level Threads

First-class User Level Threads First-class User Level Threads based on paper: First-Class User Level Threads by Marsh, Scott, LeBlanc, and Markatos research paper, not merely an implementation report User-level Threads Threads managed

More information

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Operating Systems Concepts: Chapter 7: Scheduling Strategies Operating Systems Concepts: Chapter 7: Scheduling Strategies Olav Beckmann Huxley 449 http://www.doc.ic.ac.uk/~ob3 Acknowledgements: There are lots. See end of Chapter 1. Home Page for the course: http://www.doc.ic.ac.uk/~ob3/teaching/operatingsystemsconcepts/

More information

Embedded Systems. 6. Real-Time Operating Systems

Embedded Systems. 6. Real-Time Operating Systems Embedded Systems 6. Real-Time Operating Systems Lothar Thiele 6-1 Contents of Course 1. Embedded Systems Introduction 2. Software Introduction 7. System Components 10. Models 3. Real-Time Models 4. Periodic/Aperiodic

More information

Process Management. Processes. CS 502 Spring 99 WPI MetroWest/Southboro Campus

Process Management. Processes. CS 502 Spring 99 WPI MetroWest/Southboro Campus Process Management CS 502 Spring 99 WPI MetroWest/Southboro Campus Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Threads Interprocess Communication 1 1 Process

More information

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum Scheduling Yücel Saygın These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum 1 Scheduling Introduction to Scheduling (1) Bursts of CPU usage alternate with periods

More information

SYSTEM ecos Embedded Configurable Operating System

SYSTEM ecos Embedded Configurable Operating System BELONGS TO THE CYGNUS SOLUTIONS founded about 1989 initiative connected with an idea of free software ( commercial support for the free software ). Recently merged with RedHat. CYGNUS was also the original

More information

Operating System. Lecture Slides By Silberschatz, Galvin & Gagne (8 th Edition) Modified By: Prof. Mitul K. Patel

Operating System. Lecture Slides By Silberschatz, Galvin & Gagne (8 th Edition) Modified By: Prof. Mitul K. Patel Operating System Lecture Slides By Silberschatz, Galvin & Gagne (8 th Edition) Modified By: Prof. Mitul K. Patel Shree Swami Atmanand Saraswati Institute of Technology, Surat January 2012 Outline 1 Chapter

More information

Monitors, Java, Threads and Processes

Monitors, Java, Threads and Processes Monitors, Java, Threads and Processes 185 An object-oriented view of shared memory A semaphore can be seen as a shared object accessible through two methods: wait and signal. The idea behind the concept

More information

Thread states. Java threads: synchronization. Thread states (cont.)

Thread states. Java threads: synchronization. Thread states (cont.) Thread states Java threads: synchronization 1. New: created with the new operator (not yet started) 2. Runnable: either running or ready to run 3. Blocked: deactivated to wait for something 4. Dead: has

More information

Threads & Introduction to CPU Scheduling

Threads & Introduction to CPU Scheduling Threads & Introduction to CPU Scheduling Mohammad S. Hasan Staffordshire University, UK Threads & Introduction to CPU Scheduling Slide 1 Lecture Outline Definition of a thread and types CPU -I/O burst

More information

Embedded Systems. Chapter 6. Real-Time Operating System

Embedded Systems. Chapter 6. Real-Time Operating System Embedded Systems Chapter 6 Real-Time Operating System 6. Real-Time Operating System [8 Hrs.] 6.1 Operating System Basics 6.2 Task, Process, and Threads 6.3 Multiprocessing and Multitasking 6.4 Task Scheduling

More information

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings Operatin g Systems: Internals and Design Principle s Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings Operating Systems: Internals and Design Principles Bear in mind,

More information

Operating Systems. III. Scheduling. http://soc.eurecom.fr/os/

Operating Systems. III. Scheduling. http://soc.eurecom.fr/os/ Operating Systems Institut Mines-Telecom III. Scheduling Ludovic Apvrille ludovic.apvrille@telecom-paristech.fr Eurecom, office 470 http://soc.eurecom.fr/os/ Outline Basics of Scheduling Definitions Switching

More information

Ser321 Principles of Distributed Software Systems 5. Threads

Ser321 Principles of Distributed Software Systems 5. Threads Ser321 Principles of Distributed Software Systems 5. Threads Principles of Distributed Software Systems T. Lindquist 2015 August 2015 Page 1 5.a.1 5.a Background on Programming with Concurrency Motivation

More information

Instituto de Ciências Matemáticas e de Computação Departamento de Sistemas de Computação

Instituto de Ciências Matemáticas e de Computação Departamento de Sistemas de Computação Instituto de Ciências Matemáticas e de Computação Departamento de Sistemas de Computação SSC-0541 Sistemas Operacionais I 2º Semestre 2014 1ª Lista de Exercícios Extraída da 9ª edição em Inglês do Livro

More information

Admin. Threads, CPU Scheduling. Yesterday s Lecture: Threads. Today s Lecture. ITS 225: Operating Systems. Lecture 4

Admin. Threads, CPU Scheduling. Yesterday s Lecture: Threads. Today s Lecture. ITS 225: Operating Systems. Lecture 4 ITS 225: Operating Systems Admin Lecture 4 Threads, CPU Scheduling Jan 23, 2004 Dr. Matthew Dailey Information Technology Program Sirindhorn International Institute of Technology Thammasat University Some

More information

CPU Scheduling. CS439: Principles of Computer Systems September 7, 2016

CPU Scheduling. CS439: Principles of Computer Systems September 7, 2016 CPU Scheduling CS439: Principles of Computer Systems September 7, 2016 Last Time A process is a unit of execution Defines an address space An abstraction for protection Processes are represented as Process

More information

Midterm Review. System Software

Midterm Review. System Software CS 325 Principles of Operating Systems Midterm Review Dr. Xiao Qin New Mexico Tech http://www.cs.nmt.edu/~xqin xqin@cs.nmt.edu Spring, 2007 These slides are adapted from notes by Dr. Gary Nutt (University

More information

Kernel comparison of OpenSolaris, Windows Vista and. Linux 2.6

Kernel comparison of OpenSolaris, Windows Vista and. Linux 2.6 Kernel comparison of OpenSolaris, Windows Vista and Linux 2.6 The idea of writing this paper is evoked by Max Bruning's view on Solaris, BSD and Linux. The comparison of advantages and disadvantages among

More information

Operating system Dr. Shroouq J. CPU SCHEDULING

Operating system Dr. Shroouq J. CPU SCHEDULING CPU SCHEDULING CPU scheduling is the basis of multiprogrammed operating systems. By switching the CPU among processes, the operating system can make the computer more productive. 6.1 Basic Concepts The

More information

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) CPU Scheduling: Overview. Scheduling: Components

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) CPU Scheduling: Overview. Scheduling: Components Outline V22.0202-001 Computer Systems Organization II (Honors) (Introductory Operating Systems) Lecture 10 CPU Scheduling February 23, 2005 Announcements Lab 3 due on March 2 nd, Demos on March 2 nd and

More information

Synchronization Possibilities and Features in Java

Synchronization Possibilities and Features in Java Abstract Synchronization Possibilities and Features in Java Beqir Hamidi Lindita Hamidi ILIRIA College Bregu i Diellit, st. Gazmend Zajmi, no. 75 p.n., 10 000 Prishtine-Kosove -Prishtine beqirhamidi@hotmail.com,

More information

Threads and Synchronization

Threads and Synchronization Threads and Synchronization Mark Allen Weiss Copyright 2000 1 What threads are Outline of Topics The Thread class and starting some threads Synchronization: keeping threads from clobbering each other Deadlock

More information

Operating Systems Part of E1.9 - Principles of Computers and Software Engineering. Lecture 3: Introduction to process management

Operating Systems Part of E1.9 - Principles of Computers and Software Engineering. Lecture 3: Introduction to process management Operating Systems Part of E1.9 - Principles of Computers and Software Engineering Lecture 3: Introduction to process management Objectives To introduce the concepts of: Process state and process control

More information

Topics. What is a thread? Thread states Thread priorities Thread class Two ways of creating Java threads

Topics. What is a thread? Thread states Thread priorities Thread class Two ways of creating Java threads Java Threads 1 Topics What is a thread? Thread states Thread priorities Thread class Two ways of creating Java threads Extending Thread class Implementing Runnable interface ThreadGroup Synchronization

More information

CPU Scheduling. CPU Scheduling. Scheduling criteria. Scheduling criteria. FCFS continued. Example: FCFS Scheduling

CPU Scheduling. CPU Scheduling. Scheduling criteria. Scheduling criteria. FCFS continued. Example: FCFS Scheduling CPU Scheduling CPU Scheduling The scheduling problem: - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s) When do we make decision? Scheduling decisions may take place when

More information

Performance Comparison of RTOS

Performance Comparison of RTOS Performance Comparison of RTOS Shahmil Merchant, Kalpen Dedhia Dept Of Computer Science. Columbia University Abstract: Embedded systems are becoming an integral part of commercial products today. Mobile

More information

Chapter 5: CPU Scheduling

Chapter 5: CPU Scheduling Chapter 5: CPU Scheduling Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Thread Scheduling Operating Systems Examples

More information

5) One class of services provided by an operating system is to provide new functionality that is not supported directly by the underlying hardware.

5) One class of services provided by an operating system is to provide new functionality that is not supported directly by the underlying hardware. Benha University 2 nd Term (May 2014) Final Exam Class: 3 rd Year Students Subject: Operating Systems Faculty of Computers & Informatics Date: 17/5/2014 Time: 3 hours Answer the following questions:- Question

More information

Operating Systems 4 th Class

Operating Systems 4 th Class Operating Systems 4 th Class Lecture 1 Operating Systems Operating systems are essential part of any computer system. Therefore, a course in operating systems is an essential part of any computer science

More information

What Is an RTOS and Why U se Use One? May, May 2013

What Is an RTOS and Why U se Use One? May, May 2013 What Is an RTOS and Why Use One? May, 2013 What is an Embedded System? Dedicated to a specific purpose Components: Microprocessor Application program Real-Time Operating System (RTOS) RTOS and application

More information

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015 Operating Systems 05. Threads Paul Krzyzanowski Rutgers University Spring 2015 February 9, 2015 2014-2015 Paul Krzyzanowski 1 Thread of execution Single sequence of instructions Pointed to by the program

More information

CS420: Operating Systems

CS420: Operating Systems CPU Scheduling James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Scheduling Concepts

More information

Topics. Producing Production Quality Software. Concurrent Environments. Why Use Concurrency? Models of concurrency Concurrency in Java

Topics. Producing Production Quality Software. Concurrent Environments. Why Use Concurrency? Models of concurrency Concurrency in Java Topics Producing Production Quality Software Models of concurrency Concurrency in Java Lecture 12: Concurrent and Distributed Programming Prof. Arthur P. Goldberg Fall, 2005 2 Why Use Concurrency? Concurrent

More information

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1 Module 8 Industrial Embedded and Communication Systems Version 2 EE IIT, Kharagpur 1 Lesson 37 Real-Time Operating Systems: Introduction and Process Management Version 2 EE IIT, Kharagpur 2 Instructional

More information

Introduction. What is an Operating System?

Introduction. What is an Operating System? Introduction What is an Operating System? 1 What is an Operating System? 2 Why is an Operating System Needed? 3 How Did They Develop? Historical Approach Affect of Architecture 4 Efficient Utilization

More information

Chapter 5: CPU Scheduling!

Chapter 5: CPU Scheduling! Chapter 5: CPU Scheduling Operating System Concepts 8 th Edition, Silberschatz, Galvin and Gagne 2009 Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling

More information

REAL TIME OPERATING SYSTEMS. Lesson-10:

REAL TIME OPERATING SYSTEMS. Lesson-10: REAL TIME OPERATING SYSTEMS Lesson-10: Real Time Operating System 1 1. Real Time Operating System Definition 2 Real Time A real time is the time which continuously increments at regular intervals after

More information

Chapter 6 Concurrency: Deadlock and Starvation

Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 6 Concurrency: Deadlock and Starvation Dave Bremer Otago Polytechnic, N.Z. 2008, Prentice Hall Roadmap Principals of Deadlock

More information

Process Scheduling CS 241. February 24, 2012. Copyright University of Illinois CS 241 Staff

Process Scheduling CS 241. February 24, 2012. Copyright University of Illinois CS 241 Staff Process Scheduling CS 241 February 24, 2012 Copyright University of Illinois CS 241 Staff 1 Announcements Mid-semester feedback survey (linked off web page) MP4 due Friday (not Tuesday) Midterm Next Tuesday,

More information

CPU Scheduling. CPU Scheduling. Scheduling criteria. Scheduling criteria. FCFS continued. Example: FCFS Scheduling

CPU Scheduling. CPU Scheduling. Scheduling criteria. Scheduling criteria. FCFS continued. Example: FCFS Scheduling CPU Scheduling CPU Scheduling new admitted interrupt exit terminated ready running I/O or event completion scheduler dispatch waiting I/O or event wait The scheduling problem: - Have K jobs ready to run

More information

Robotics and Autonomous Systems

Robotics and Autonomous Systems Robotics and Autonomous Systems Lecture 10: Threads and Multitasking Robots Simon Parsons Department of Computer Science University of Liverpool 1 / 38 Today Some more programming techniques that will

More information

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition,

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition, Chapter 5: CPU Scheduling, Silberschatz, Galvin and Gagne 2009 Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Linux Example

More information

Multi-core Programming System Overview

Multi-core Programming System Overview Multi-core Programming System Overview Based on slides from Intel Software College and Multi-Core Programming increasing performance through software multi-threading by Shameem Akhter and Jason Roberts,

More information

G52CON: Concepts of Concurrency

G52CON: Concepts of Concurrency G52CON: Concepts of Concurrency Lecture 11 Synchronisation in Java" Brian Logan School of Computer Science bsl@cs.nott.ac.uk Outline of this lecture" mutual exclusion in Java condition synchronisation

More information

EE458 - Embedded Systems Lecture 5 Intro to RTOSes

EE458 - Embedded Systems Lecture 5 Intro to RTOSes EE458 - Embedded Systems Lecture 5 Intro to RTOSes Outline RTOS Components Multitasking Objects Services Key Characteristics of an RTOS RTEMS Key Concepts References RTC: Chapter 4 CUG: Chapter 2 1 Introduction

More information

Copyright 2010, Elsevier Inc. All rights Reserved

Copyright 2010, Elsevier Inc. All rights Reserved An Introduction to Parallel Programming Peter Pacheco Chapter 4 Shared Memory Programming with Pthreads 1 Roadmap! Problems programming shared memory systems.! Controlling access to a critical section.!

More information

Tools Page 1 of 13 ON PROGRAM TRANSLATION. A priori, we have two translation mechanisms available:

Tools Page 1 of 13 ON PROGRAM TRANSLATION. A priori, we have two translation mechanisms available: Tools Page 1 of 13 ON PROGRAM TRANSLATION A priori, we have two translation mechanisms available: Interpretation Compilation On interpretation: Statements are translated one at a time and executed immediately.

More information

Processor Scheduling. Queues Recall OS maintains various queues

Processor Scheduling. Queues Recall OS maintains various queues Processor Scheduling Chapters 9 and 10 of [OS4e], Chapter 6 of [OSC]: Queues Scheduling Criteria Cooperative versus Preemptive Scheduling Scheduling Algorithms Multi-level Queues Multiprocessor and Real-Time

More information

UNIT 1 OPERATING SYSTEM FOR PARALLEL COMPUTER

UNIT 1 OPERATING SYSTEM FOR PARALLEL COMPUTER UNIT 1 OPERATING SYSTEM FOR PARALLEL COMPUTER Structure Page Nos. 1.0 Introduction 5 1.1 Objectives 5 1.2 Parallel Programming Environment Characteristics 6 1.3 Synchronisation Principles 1.3.1 Wait Protocol

More information

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking? Housekeeping Paper reading assigned for next Thursday Scheduling Lab 2 due next Friday Don Porter CSE 506 Lecture goals Undergrad review Understand low-level building blocks of a scheduler Understand competing

More information

OPERATING SYSTEMS (OPS)

OPERATING SYSTEMS (OPS) Computing Curricula - Computer Engineering Body of Knowledge 1 OPERATING SYSTEMS (OPS) OPS0. History and overview of operating systems [core] OPS1. Operating system function and design [core] OPS2. Operating

More information

Comprehensive support for general-purpose concurrent programming; partitioned into three packages:

Comprehensive support for general-purpose concurrent programming; partitioned into three packages: Java 1.5 Concurrency Utilities Comprehensive support for general-purpose concurrent programming; partitioned into three packages: java.util.concurrent support common concurrent programming paradigms, e.g.,

More information

COS 318: Operating Systems. CPU Scheduling. (http://www.cs.princeton.edu/courses/cos318/)

COS 318: Operating Systems. CPU Scheduling. (http://www.cs.princeton.edu/courses/cos318/) COS 318: Operating Systems CPU Scheduling (http://www.cs.princeton.edu/courses/cos318/) Today s Topics! CPU scheduling! CPU Scheduling algorithms 2 When to Schedule?! Process/thread creation! Process/thread

More information

Why Threads Are A Bad Idea (for most purposes)

Why Threads Are A Bad Idea (for most purposes) Why Threads Are A Bad Idea (for most purposes) John Ousterhout Sun Microsystems Laboratories john.ousterhout@eng.sun.com http://www.sunlabs.com/~ouster Introduction Threads: Grew up in OS world (processes).

More information

ELEC 377 Operating Systems. Thomas R. Dean

ELEC 377 Operating Systems. Thomas R. Dean ELEC 377 Operating Systems Thomas R. Dean Instructor Tom Dean Office:! WLH 421 Email:! tom.dean@queensu.ca Hours:! Wed 14:30 16:00 (Tentative)! and by appointment! 6 years industrial experience ECE Rep

More information

CHAPTER 15: Operating Systems: An Overview

CHAPTER 15: Operating Systems: An Overview CHAPTER 15: Operating Systems: An Overview The Architecture of Computer Hardware, Systems Software & Networking: An Information Technology Approach 4th Edition, Irv Englander John Wiley and Sons 2010 PowerPoint

More information

Lecture 25 Symbian OS

Lecture 25 Symbian OS CS 423 Operating Systems Design Lecture 25 Symbian OS Klara Nahrstedt Fall 2011 Based on slides from Andrew S. Tanenbaum textbook and other web-material (see acknowledgements) cs423 Fall 2011 1 Overview

More information

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances: Scheduling Scheduling Scheduling levels Long-term scheduling. Selects which jobs shall be allowed to enter the system. Only used in batch systems. Medium-term scheduling. Performs swapin-swapout operations

More information

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run SFWR ENG 3BB4 Software Design 3 Concurrent System Design 2 SFWR ENG 3BB4 Software Design 3 Concurrent System Design 11.8 10 CPU Scheduling Chapter 11 CPU Scheduling Policies Deciding which process to run

More information

Chapter 6. Buffer cache. Code: Data structures

Chapter 6. Buffer cache. Code: Data structures DRAFT as of September 23, 2010: Copyright 2009 Cox, Kaashoek, Morris Chapter 6 Buffer cache One of an operating system s central roles is to enable safe cooperation between processes sharing a computer.

More information

CS11 Java. Fall 2014-2015 Lecture 7

CS11 Java. Fall 2014-2015 Lecture 7 CS11 Java Fall 2014-2015 Lecture 7 Today s Topics! All about Java Threads! Some Lab 7 tips Java Threading Recap! A program can use multiple threads to do several things at once " A thread can have local

More information

THE UNIVERSITY OF AUCKLAND

THE UNIVERSITY OF AUCKLAND THE UNIVERSITY OF AUCKLAND 07.340 T07.340 EXAMINATION FOR BA BSc ETC 1995 COMPUTER SCIENCE Operating Systems ( Time allowed : THREE hours ) NOTES: Answer SIX questions. The total mark for each question

More information

Programming Language Concepts: Lecture 12

Programming Language Concepts: Lecture 12 Programming Language Concepts: Lecture 12 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 12, 04 March 2009 Concurrent

More information

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems Lecture Outline Operating Systems Objectives Describe the functions and layers of an operating system List the resources allocated by the operating system and describe the allocation process Explain how

More information

This tutorial will take you through step by step approach while learning Operating System concepts.

This tutorial will take you through step by step approach while learning Operating System concepts. About the Tutorial An operating system (OS) is a collection of software that manages computer hardware resources and provides common services for computer programs. The operating system is a vital component

More information

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18 PROCESS VIRTUAL MEMORY CS124 Operating Systems Winter 2013-2014, Lecture 18 2 Programs and Memory Programs perform many interactions with memory Accessing variables stored at specific memory locations

More information

W4118 Operating Systems. Instructor: Junfeng Yang

W4118 Operating Systems. Instructor: Junfeng Yang W4118 Operating Systems Instructor: Junfeng Yang Outline Introduction to scheduling Scheduling algorithms 1 Direction within course Until now: interrupts, processes, threads, synchronization Mostly mechanisms

More information

Chapter 2 Operating System Overview

Chapter 2 Operating System Overview Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 2 Operating System Overview Dave Bremer Otago Polytechnic, N.Z. 2008, Prentice Hall Roadmap Operating System Objectives/Functions

More information

CPU Scheduling. User/Kernel Threads. Mixed User/Kernel Threads. Solaris/Linux Threads. CS 256/456 Dept. of Computer Science, University of Rochester

CPU Scheduling. User/Kernel Threads. Mixed User/Kernel Threads. Solaris/Linux Threads. CS 256/456 Dept. of Computer Science, University of Rochester CPU Scheduling CS 256/456 Dept. of Computer Science, University of Rochester User/Kernel Threads User threads Thread data structure is in user-mode memory scheduling/switching done at user mode Kernel

More information

Chapter 5 Process Scheduling

Chapter 5 Process Scheduling Chapter 5 Process Scheduling CPU Scheduling Objective: Basic Scheduling Concepts CPU Scheduling Algorithms Why Multiprogramming? Maximize CPU/Resources Utilization (Based on Some Criteria) CPU Scheduling

More information

Operating System: Scheduling

Operating System: Scheduling Process Management Operating System: Scheduling OS maintains a data structure for each process called Process Control Block (PCB) Information associated with each PCB: Process state: e.g. ready, or waiting

More information

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification Introduction Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification Advanced Topics in Software Engineering 1 Concurrent Programs Characterized by

More information

Last Class: Threads and Scheduling! Today: More on Scheduling Algorithms!

Last Class: Threads and Scheduling! Today: More on Scheduling Algorithms! Last Class: Threads and Scheduling! Thread: sequential execution stream within a process Kernel threads versus user-level threads Goals for Scheduling: Minimize average response time Maximize throughput

More information

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No. # 26 Real - Time POSIX. (Contd.) Ok Good morning, so let us get

More information

Chapter 6 CPU Scheduling. Contents

Chapter 6 CPU Scheduling. Contents Contents 1. Introduction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization 8. Deadlocks 9. Memory Management 10. Virtual

More information