Application Interface

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Chap 4 Multithreaded Programming. Thread A thread is a basic unit of CPU utilization It comprises a thread ID, a program counter, a register set and a.
Chapter 5 Threads os5.
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 7 Chapter 4: Threads (cont)
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
3.5 Interprocess Communication
Threads CSCI 444/544 Operating Systems Fall 2008.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Thread definitions and relationship to process Multithreading.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Operating System Concepts Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
PREPARED BY : MAZHAR JAVED AWAN BSCS-III Process Communication & Threads 4 December 2015.
Multithreaded Programing. Outline Overview of threads Threads Multithreaded Models  Many-to-One  One-to-One  Many-to-Many Thread Libraries  Pthread.
Chapter 4: Multithreaded Programming. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts What is Thread “Thread is a part of a program.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Cooperating Processes The concurrent processes executing in the operating system may be either independent processes or cooperating processes. A process.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Chapter 4 – Thread Concepts
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
Chapter 4: Threads.
OPERATING SYSTEM CONCEPT AND PRACTISE
Chapter 4: Threads.
Chapter 3: Process Concept
Operating System Concepts
Chapter 4 – Thread Concepts
Chapter 5: Threads Overview Multithreading Models Threading Issues
Operating System (013022) Dr. H. Iwidat
Chapter 3 Threads and Multithreading
Chapter 4: Multithreaded Programming
Process Management Presented By Aditya Gupta Assistant Professor
Processes Overview: Process Concept Process Scheduling
Chapter 4 Threads.
Nadeem MajeedChoudhary.
Chapter 4: Threads.
Threads & multithreading
Operating System Concepts
Chapter 4: Threads.
Chapter 4: Threads.
OPERATING SYSTEMS Threads
CSE 542: Operating Systems
Modified by H. Schulzrinne 02/15/10 Chapter 4: Threads.
Mid Term review CSC345.
Chapter 4: Threads.
Threads Chapter 4.
Chapter 4: Threads.
Multithreaded Programming
CSE 542: Operating Systems
Prof. Leonardo Mostarda University of Camerino
Chapter 4: Threads.
Chapter 4: Threads.
CSE 542: Operating Systems
Chapter 4: Threads.
CSE 542: Operating Systems
Outline Chapter 3: Processes Chapter 4: Threads So far - Next -
Chapter 4: Threads.
CSE 542: Operating Systems
Chapter 4: Threads.
Presentation transcript:

Application Interface Unstructured MS Dos Event driven PalmOS File system based UNIX, Plan 9 Object oriented Hydra, OPAL Distributed OS Amoeba Real time QNX Single Address Space OS (SASOS) OPAL 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Outline Chapter 4: Processes Chapter 5: Threads Introduction to Threads: Birrell 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Processes Process is a program in execution Program code Data section Execution context: Program counter, registers, stack Process has thread(s) of control Many processes “run” concurrently: Process scheduling Fair allocation of CPU and I/O bound processes Context switch 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Process States 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Process Control Block 10-Dec-18 CSE 542: Operating Systems

Process context switch 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Process creation Creating new processes is expensive Resource allocation issue Fork mechanism: UNIX, Windows NT Duplicate the parent process Shares file descriptors, memory is copied Exec to create different process Various optimizations to avoid copying the entire parent context (Copy on write (COW), etc..) Exec mechanism: VMS, Windows NT New process is specifically loaded 10-Dec-18 CSE 542: Operating Systems

Interprocess communication Processes need to communicate with each other Naming Message-passing Direct (to process) or indirect (port, mailbox) Symmetric or asymmetric (blocking, nonblocking) Automatic or explicit buffering (capacity) Send by copy or reference Fixed size or variable size messages Shared memory/mutexes Remote Procedure Call (RPC/RMI) Bounded buffer problem 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems CPU scheduling Interleave processes so as to maximize utilization of CPU and I/O resources Scheduler should be fast as time spent in scheduler is wasted time Switching context (h/w assists – register windows [sparc]) Switching to user mode Jumping to proper location Preemptive scheduling: Process could be in the middle of an operation Especially bad for kernel structures Non-preemptive (cooperative) scheduling: Starvation 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Threads Applications require concurrency. Threads provide a neat abstraction to specify concurrency E.g. word processor application Needs to accept user input, display it on screen, spell check and grammar check Implicit: Write code that reads user input, displays/formats it on screen, calls spell checked etc. while making sure that interactive response does not suffer. May or may not leverage multiple processors Threads: Use threads to perform each task and communicate using queues and shared data structures Processes: expensive to create and do not share data structures and so explicitly passed 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Threaded application 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Threads - Benefits Responsiveness If one “task” takes too long, other “tasks” can still proceed Resource sharing: Grammar checker can check the buffer as it is being typed Economy: Process creation is expensive (spell checker) Utilization of multiprocessor architectures: If we had four processors (say), the word processor can fully leverage them Pitfalls: Shared data should be protected or results are undefined Race conditions, dead locks, starvation (more later) 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Thread types Continuum: Cost to create and ease of management User level threads (e.g. pthreads) Implemented as a library Fast to create Cannot have blocking system calls Scheduling conflicts between kernel and threads. User level threads cannot do anything is kernel preempts the process Kernel level threads Slower to create and manage Blocking system calls are no problem Most OS’s support these threads 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Threading models One to One model Map each user thread to one kernel thread Many to one model Map many user threads to a single kernel thread Cannot exploit multiprocessors Many to many Map m user threads to n kernel threads 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Threading Issues: Cancellation: Asynchronous or deferred cancellation Signal handling: Relevant thread Every thread Certain threads Specific thread Pooled threads (web server) Thread specific data 10-Dec-18 CSE 542: Operating Systems

Threads – Andrew Birrell Seminal paper on threads programming Old but most techniques/experiences are still valid Birrell Xerox PARCDec SRC Microsoft Research Invented Remote Procedure Calls (RPC) Personal Juke box (hard disk based mp3 – Apple iPOD?) Worked on Cedar, Distributed FS etc for ~25 years (1977- 10-Dec-18 CSE 542: Operating Systems

Threads – Andrew Birrell Dec SRC and Xerox PARC were the premium systems research labs PARC researchers invented: Personal computers - Alto Mouse Windows - Star Bitmapped terminals Icons Ethernet Smalltalk Bravo – first WYSIWYG program Laser printer … 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Windows 2000 10-Dec-18 CSE 542: Operating Systems

Wizard ‘ps -cfLeP’ output UID PID PPID LWP PSR NLWP CLS PRI STIME TTY LTIME CMD root 0 0 1 - 1 SYS 96 Aug 03 ? 0:01 sched root 1 0 1 - 1 TS 59 Aug 03 ? 7:12 /etc/init - root 2 0 1 - 1 SYS 98 Aug 03 ? 0:00 pageout root 3 0 1 - 1 SYS 60 Aug 03 ? 275:46 fsflush root 477 352 1 - 1 IA 59 Aug 03 ?? 0:0 /usr/openwin/bin/fbconsole -d :0 root 62 1 14 - 14 TS 59 Aug 04 ? 0:00 /usr/lib/sysevent/syseventd 10-Dec-18 CSE 542: Operating Systems

CSE 542: Operating Systems Discussion Constant tension between moving functionality to upper layers; involving the application programmer and performing automatically at the lower layers Automatically create/manage threads by compiler/ system? (open research question) 10-Dec-18 CSE 542: Operating Systems