Processes Creation and Threads

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
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.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
UNIX Process Control Bach 7 Operating Systems Course Hebrew University Spring 2007.
Processes CSCI 444/544 Operating Systems Fall 2008.
CSE 451: Operating Systems Winter 2009 Module 4 Processes Mark Zbikowski Gary Kimura.
1 What is a Process ? The activity of program execution. Also called a task or job Has associated with it: Code Data Resources A State An executing set.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads. 4.2CSCI 380 Operating Systems Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 4 Operating Systems.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
The process concept (section 3.1, 3.3 and demos)  Process: An entity capable of requesting and using computer resources (memory, CPU cycles, files, etc).
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 6 System Calls OS System.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Operating Systems Process Creation
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 14 Threads 2 Read Ch.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
4300 Lines Added 1800 Lines Removed 1500 Lines Modified PER DAY DURING SUSE Lab.
Lecture 3 Threads Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
CS 390 Unix Programming Environment
Processes and Threads MICROSOFT.  Process  Process Model  Process Creation  Process Termination  Process States  Implementation of Processes  Thread.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
Operating System Concepts
CISC2200 Threads Fall 09. Process  We learn the concept of process  A program in execution  A process owns some resources  A process executes a program.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Lecture 5 Page 1 CS 111 Online Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Threads Some of these slides were originally made by Dr. Roger deBry. They include text, figures, and information from this class’s textbook, Operating.
OPERATING SYSTEM CONCEPT AND PRACTISE
Chapter 4: Threads.
Chapter 3: Process Concept
CS 6560: Operating Systems Design
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Chapter 4: Threads.
Operating System (013022) Dr. H. Iwidat
Process Management Presented By Aditya Gupta Assistant Professor
Unix Process Management
Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command Some by invocation from other running.
Example questions… Can a shell kill itself? Can a shell within a shell kill the parent shell? What happens to background processes when you exit from.
Threads and Locks.
Chapter 4: Threads.
Lecture 2: Processes Part 1
ICS 143 Principles of Operating Systems
Threads and Data Sharing
Process Models, Creation and Termination
OPERATING SYSTEMS Threads
Cs561 Presenter: QIAOQIAO CHEN Spring 2012
Interprocess Communication
Chapter 4: Threads.
CSE 451: Operating Systems Winter 2010 Module 4 Processes
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Chapter 4: Threads.
Chapter 3: Processes.
Chapter 4: Threads.
CS510 Operating System Foundations
Lab 6: Process Management
Chapter 4: Threads.
Outline Chapter 3: Processes Chapter 4: Threads So far - Next -
Chapter 4: Threads.
Lecture 6 Introduction to Process Management
Chapter 4: Threads.
Chapter 3: Process Management
Chapter 4:Threads Book: Operating System Principles , 9th Edition , Abraham Silberschatz, Peter Baer Galvin, Greg Gagne.
Presentation transcript:

Processes Creation and Threads

Creation of Processes Creation is very specific to an operating system. OS needs to: Reserve memory for process Add entry in process table Load the application code (optional?) All systems start from a single process.

Process Creation Calc.exe MyApp.exe CreateProcess(“calc”)

Linux Process Based on a system call named fork(). Syntax: pid_t fork(); Duplicates the process calling this function. The new process is called the child, the original process is called the parent.

Linux Processes The child process will see 0 returned from the fork() call, the parent will see the process id of the new process. Often the new process will want to execute other command rather than just being a duplicate. Uses exec() function.

Example Unix call Main() { do_something(); if (fork() == 0) { // this is the child process execl(“xcalculator”); } // the child process will never make it here! do_morestuff();

What Happens Here? main() { while (1) fork(); }

Timeline xcalculator MyApp exec() MyApp MyApp fork()

Terminating a Process Memory needs to be released Entry needs to be removed from process table. Usually the process asks to terminate itself! Program calls ExitProcess() or exit(). If your program doesn’t call this, the library (Java, C run time) will call it.

Terminating Other Processes Can one process ask another to stop? If the first process has enough permission then yes. OS will not deliver the message otherwise. The process sends a special signal to the other process. TerminateProcess (Windows) kill (Linux)

Other Techniques The OS will remove any process that has caused a fault. “This application has performed an illegal operating and will be shut down.”

Design of an E-mail Client We design an e-mail client like Outlook. Problem: Our e-mail client will notify the user when new mail comes in (even if they are creating a new message).

Attempt #1 Forever() { wait for a key add key to the new message if (new mail) { play notification }

Attempt #2 Forever() { wait for a key but no longer than 1 second if (key pressed) { add character to message } if (new mail) { play notification

Divide The Problem! // checking for new mail Forever() { sleep for an amount of time (or better yet block) if (new mail) play notification } // Handling keyboard wait for key (yes, block waiting for the key) add character to mail message

Two separate programs? If we could run both of these loops at the same time, our problem would be easier! Two processes are possible but sharing information between them is not convenient.

Thread A thread is a sequence of instructions. Each process contains at least 1 thread. Many OS allow for multiple threads within a single process. Often called a lightweight process. Provides multi-tasking within a single process.

Threads Threads have access to all variables that are within the same program. If you have a global, you can read it or change it. No security between threads of a single process Easy to share information Easy to make mistakes!

Reasons for Threads Can simplify problems On multi-core processors two threads can run simultaneously. Programs need to take advantage of this