SlideShare a Scribd company logo
Sanjivani Rural Education Society’s
Sanjivani College of Engineering, Kopargaon-423 603
(An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune)
NAAC ‘A’ Grade Accredited, ISO 9001:2015 Certified
Department of Computer Engineering
(NBA Accredited)
Prof. A. V. Brahmane
Assistant Professor
E-mail : brahmaneanilkumarcomp@sanjivani.org.in
Contact No: 91301 91301 Ext :145, 9922827812
Subject- Operating System and Administration (CO2013)
Unit III- The Structure of Process, Process Control and
Process Scheduling
Content
• Process state and transitions,
• Layout of the system memory,
• Context of the process,
• Saving the context of the process,
• Manipulation the process address space,
• Sleep,
• Process creation,
• Signal,
• Process termination, Awaiting the process termination,
• Invoking other program, Process Scheduling
• Case Study - Access Control, Rootly Powers and Controlling Processes
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Process Control – Scheduling
• The relationship between the system calls and memory management algorithms
is shown in the following diagram:
• Almost all calls use sleep and wakeup so its not shown in the figure. exec also interacts with the
file system algorithms
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Process Creation
• The only way to create a new process in UNIX is to use the fork system call. The
process which calls fork is called the parent process and the newly created
process is called the child process.
• pid = fork();
• On return of the fork system call, the two processes have identical user-level
context except for the value of pid. pid for the parent process is the process ID of
the child process. And pid for child process is 0. The process 0 is the only process
which is not created via fork.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
• The steps followed by the kernel for fork are:
• It creates a new entry in the process table.
• It assigns a unique ID to the newly created process.
• It makes a logical copy of the regions of the parent process. If a regions can be
shared, only its reference count is incremented instead of making a physical copy
of the region.
• The reference counts of file table entries and inodes of the process are increased.
• It turned the child process ID to the parent and 0 to the child.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
The algorithm fork
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Fork creating a New process context
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Signals
• Signals inform processes of the occurrence of asynchronous events. Processes
may send each other signals with the kill system call, or the kernel may send
signals internally.
• There are 19 signals in the System V (Release 2) UNIX system that can be
classified as follows:
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Signal Classifications
• Signals having to do with the termination of a process, send when a process exits or when a process invokes
the signal system call with the death of child parameter.
• Signals having to do with process induced exceptions such as when a process accesses an address outside its
virtual address space, when it attempts to write memory that is read-only (such as program text), or when it
executes a privileged instruction or for various hardware errors.
• Signals having to do with the unrecoverable conditions during a system call, such as running out of system
resources during exec after the original address space has been released
• Signals caused by an unexpected error condition during a system call, such as making a nonexistent system
call (the process passed a system call number that does not correspond to a legal system call), writing a pipe
that has no reader processes, or using an illegal "reference" value for the lseek system call. It would be more
consistent to return an error on such system calls instead of generating a signal, but the use of signals to
abort misbehaving processes is more pragmatic.
• Signals originating from a process in user mode, such as when a process wishes to receive an alarm signal
after a period of time, or when processes send arbitrary signals to each other with the kill system call.
• Signals related to terminal interaction such as when a user hands up a terminal (or the "carrier" signal drops
on such a line for any reason), or when a user presses the "break" or "delete" keys on a terminal keyboard.
• Signals for tracing execution of a process.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Checking and Handling Signals in the Process State Diagram
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
The algorithm issig
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Handling Signals
• The handling of signal is done through the algorithm psig,
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Types of Signals
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Process Groups
• The system has to identify processes by "groups" in some cases, for instance, a
signal might relate to all the processes which are ancestors of the login shell. The
kernel uses the process group ID to identify groups of related processes that
should receive a common signal for certain events. It saves the group ID in the
process table.
• The setpgrp system call initializes the process group number of a process and sets
it equal to the value of its process ID.
• grp = setpgrp();
• where grp is the new process group number. A child retains the process group
number of its parent during fork.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Sending Signals from Processes
• Processes use the kill system call to send signals.
• kill (pid, signum);
• where pid identifies the set of processes to receive the signal, and signum is the signal number
being sent. The following list shows the correspondence between values of pid and sets of
processes.
• If pid is a positive integer, the kernel sends the signal to the process with process ID pid.
• If pid is 0, the kernel sends the signal to all processes in the sender's process group.
• If pid is -1, the kernel sends the signal to all processes whose real user ID equals the effective user
ID of the sender (real and effective user IDs are studied later). If the sending process has effective
user ID of superuser, the kernel sends the signal to all processes except processes 0 and 1.
• If pid is a negative integer but not -1, the kernel sends the signal to all processes in the process
group equal to the absolute value of pid.
• In all cases, if the sending process does not have effective user ID of superuser, or its real or
effective user ID do not match the real or effective user ID of the receiving process, kill fails.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Process Termination
• Processes on the UNIX system exit by executing the exit system call. When a
process exits, it enters the zombie state, relinquishes all of its resources, and
dismantles its context except for its process table entry.
• exit (status);
• where status is the exit code returned to the parent. The process may
call exit explicitly, but the startup routine in C calls exit after the main function
returns. The kernel may call exit on receiving an uncaught signal. In such cases,
the value of status is the signal number.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
The algorithm for exit
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Awaiting Process Termination
• A process can synchronize its execution with the termination of a child process by
executing the wait system call.
• pid = wait (stat_addr);
• where pid is the process ID of the zombie child, and stat_addr is the address in
user space of an integer that will contain the exit status code of the child.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
The algorithm for wait
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Invoking Other Programs
• The exec system call overlays the address space of a process with the contents of
an executable file.
• execve (filename, argv, envp)
• where filename is name of the file being invoked, argv is a pointer to array of
character pointers which are arguments to the program in the executable file,
and envp is a pointer to array of character pointers which are the environment of
the executed program. There are several library functions that call exec,
like execl, execv, execle, and so on. All call execve eventually. The character strings
in the envp array are of the form, "name=value". C programs can access the
environment variables by accessing the global variable environ, initialized by the
C startup routine.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
The algorithm for exec
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
The User ID of a Process
• There are two user ID associated with a process, the real user ID and the effective
user ID or setuid (set user ID). The real user ID identifies the user who is
responsible for the running process. The effective user ID is used to assign
ownership of newly created files, to check file access permissions, and to check
permission to send signals to processes via the kill system call. The kernel allows a
process to change its effective user ID when it execs a setuid program or when it
invokes the setuid system call explicitly.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
• A setuid program is an executable file that has the setuid bit set in its permission
mode field. When a process execs a setuid program, the kernel sets the effective
user ID fields in the process table and u-area to the owner ID of the file. To
distinguish the two fields, let us call the field in the process table the saved user
ID.
• setuid (uid);
• where uid is the new user ID, and its result depends on the current value of the
effective user ID. If the effective user ID of the calling process is superuser, the
kernel resets the real and effective user ID fields in the process table and u-area
to uid. If its not the superuser, the kernel resets the effective user ID in the u-area
to uid if uid has the value of the real user ID or if it has the value of the saved user
ID. Otherwise, the system call returns an error. Generally, a process inherits its
real and effective user IDs from its parent during the fork system call and
maintains their values across exec system calls.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Changing the Size of a Process
• A process can increase or decrease the size of its data region by using
the brk system call.
• brk (endds);
• where endds becomes the value of the highest virtual address of the data region
of the process (called its break value). Alternatively, a user can call
• oldendds = sbrk(increment);
• where increment changes the current break value by the specified number of
bytes, and oldendds is the break value before the call. sbrk is a C library routine
that calls brk. The kernel checks that the new process size is less than the system
maximum and that the new data region does not overlap previously assigned
virtual address space.
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
Algorithm: brk
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
•Thank you …..
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon

More Related Content

Similar to Unit 3.2 Process Control.ppt (Process Control and Scheduling)

Linux process management
Linux process managementLinux process management
Linux process management
Raghu nath
 
TAU E4S ON OpenPOWER /POWER9 platform
TAU E4S ON OpenPOWER /POWER9 platformTAU E4S ON OpenPOWER /POWER9 platform
TAU E4S ON OpenPOWER /POWER9 platform
Ganesan Narayanasamy
 
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
SatyamMishra828076
 
13 process management
13 process management13 process management
13 process management
Shay Cohen
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
stilliegeorgiana
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
denneymargareta
 
chapter2.pptx
chapter2.pptxchapter2.pptx
chapter2.pptx
PardhisCreation
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
Ziyauddin Shaik
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10
duquoi
 
07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx
KushalSrivastava23
 
Os notes
Os notesOs notes
Os notes
LakshmiSarvani6
 
Inter Process communication and Memory Management
Inter Process communication and Memory ManagementInter Process communication and Memory Management
Inter Process communication and Memory Management
PoonamChawhan1
 
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESOPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
priyasoundar
 
Systems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesSystems Programming Assignment Help - Processes
Systems Programming Assignment Help - Processes
HelpWithAssignment.com
 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
Talesun Solar USA Ltd.
 
S4: Distributed Stream Computing Platform
S4: Distributed Stream Computing PlatformS4: Distributed Stream Computing Platform
S4: Distributed Stream Computing Platform
Aleksandar Bradic
 
Implementation of Kernel API
Implementation of Kernel APIImplementation of Kernel API
Implementation of Kernel API
khushi74
 
unit-2.pdf
unit-2.pdfunit-2.pdf
unit-2.pdf
071ROHETHSIT
 
Process management
Process managementProcess management
Process management
Birju Tank
 
Processes
ProcessesProcesses
Processes
vampugani
 

Similar to Unit 3.2 Process Control.ppt (Process Control and Scheduling) (20)

Linux process management
Linux process managementLinux process management
Linux process management
 
TAU E4S ON OpenPOWER /POWER9 platform
TAU E4S ON OpenPOWER /POWER9 platformTAU E4S ON OpenPOWER /POWER9 platform
TAU E4S ON OpenPOWER /POWER9 platform
 
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
 
13 process management
13 process management13 process management
13 process management
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
 
chapter2.pptx
chapter2.pptxchapter2.pptx
chapter2.pptx
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10
 
07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx
 
Os notes
Os notesOs notes
Os notes
 
Inter Process communication and Memory Management
Inter Process communication and Memory ManagementInter Process communication and Memory Management
Inter Process communication and Memory Management
 
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESOPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
 
Systems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesSystems Programming Assignment Help - Processes
Systems Programming Assignment Help - Processes
 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
 
S4: Distributed Stream Computing Platform
S4: Distributed Stream Computing PlatformS4: Distributed Stream Computing Platform
S4: Distributed Stream Computing Platform
 
Implementation of Kernel API
Implementation of Kernel APIImplementation of Kernel API
Implementation of Kernel API
 
unit-2.pdf
unit-2.pdfunit-2.pdf
unit-2.pdf
 
Process management
Process managementProcess management
Process management
 
Processes
ProcessesProcesses
Processes
 

More from AnilkumarBrahmane2

Unit_ 5.3 Interprocess communication.pdf
Unit_ 5.3 Interprocess communication.pdfUnit_ 5.3 Interprocess communication.pdf
Unit_ 5.3 Interprocess communication.pdf
AnilkumarBrahmane2
 
Unit 5.2 Device Driver.pdf (Device Driver)
Unit 5.2 Device Driver.pdf (Device Driver)Unit 5.2 Device Driver.pdf (Device Driver)
Unit 5.2 Device Driver.pdf (Device Driver)
AnilkumarBrahmane2
 
Unit 5.1 Memory Management_Device Driver_IPC.ppt
Unit 5.1 Memory Management_Device Driver_IPC.pptUnit 5.1 Memory Management_Device Driver_IPC.ppt
Unit 5.1 Memory Management_Device Driver_IPC.ppt
AnilkumarBrahmane2
 
Unit 4 File Management System.ppt (File Services)
Unit 4 File Management System.ppt (File Services)Unit 4 File Management System.ppt (File Services)
Unit 4 File Management System.ppt (File Services)
AnilkumarBrahmane2
 
Unit 3.1 The Structure of Process, Process Control, Process Scheduling.ppt
Unit 3.1 The Structure of Process, Process Control, Process Scheduling.pptUnit 3.1 The Structure of Process, Process Control, Process Scheduling.ppt
Unit 3.1 The Structure of Process, Process Control, Process Scheduling.ppt
AnilkumarBrahmane2
 
Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)
Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)
Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)
AnilkumarBrahmane2
 
Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)
Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)
Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)
AnilkumarBrahmane2
 
Unit 1 Introduction to Operating System.ppt
Unit 1 Introduction to Operating System.pptUnit 1 Introduction to Operating System.ppt
Unit 1 Introduction to Operating System.ppt
AnilkumarBrahmane2
 

More from AnilkumarBrahmane2 (8)

Unit_ 5.3 Interprocess communication.pdf
Unit_ 5.3 Interprocess communication.pdfUnit_ 5.3 Interprocess communication.pdf
Unit_ 5.3 Interprocess communication.pdf
 
Unit 5.2 Device Driver.pdf (Device Driver)
Unit 5.2 Device Driver.pdf (Device Driver)Unit 5.2 Device Driver.pdf (Device Driver)
Unit 5.2 Device Driver.pdf (Device Driver)
 
Unit 5.1 Memory Management_Device Driver_IPC.ppt
Unit 5.1 Memory Management_Device Driver_IPC.pptUnit 5.1 Memory Management_Device Driver_IPC.ppt
Unit 5.1 Memory Management_Device Driver_IPC.ppt
 
Unit 4 File Management System.ppt (File Services)
Unit 4 File Management System.ppt (File Services)Unit 4 File Management System.ppt (File Services)
Unit 4 File Management System.ppt (File Services)
 
Unit 3.1 The Structure of Process, Process Control, Process Scheduling.ppt
Unit 3.1 The Structure of Process, Process Control, Process Scheduling.pptUnit 3.1 The Structure of Process, Process Control, Process Scheduling.ppt
Unit 3.1 The Structure of Process, Process Control, Process Scheduling.ppt
 
Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)
Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)
Unit 2.1 Introduction to Kernel.ppt (Kernel Services and Architecture)
 
Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)
Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)
Unit 2.2. Buffer Cache.pptx (Introduction to Buffer Chache)
 
Unit 1 Introduction to Operating System.ppt
Unit 1 Introduction to Operating System.pptUnit 1 Introduction to Operating System.ppt
Unit 1 Introduction to Operating System.ppt
 

Recently uploaded

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 

Recently uploaded (20)

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 

Unit 3.2 Process Control.ppt (Process Control and Scheduling)

  • 1. Sanjivani Rural Education Society’s Sanjivani College of Engineering, Kopargaon-423 603 (An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune) NAAC ‘A’ Grade Accredited, ISO 9001:2015 Certified Department of Computer Engineering (NBA Accredited) Prof. A. V. Brahmane Assistant Professor E-mail : brahmaneanilkumarcomp@sanjivani.org.in Contact No: 91301 91301 Ext :145, 9922827812 Subject- Operating System and Administration (CO2013) Unit III- The Structure of Process, Process Control and Process Scheduling
  • 2. Content • Process state and transitions, • Layout of the system memory, • Context of the process, • Saving the context of the process, • Manipulation the process address space, • Sleep, • Process creation, • Signal, • Process termination, Awaiting the process termination, • Invoking other program, Process Scheduling • Case Study - Access Control, Rootly Powers and Controlling Processes DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 3. Process Control – Scheduling • The relationship between the system calls and memory management algorithms is shown in the following diagram: • Almost all calls use sleep and wakeup so its not shown in the figure. exec also interacts with the file system algorithms DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 4. Process Creation • The only way to create a new process in UNIX is to use the fork system call. The process which calls fork is called the parent process and the newly created process is called the child process. • pid = fork(); • On return of the fork system call, the two processes have identical user-level context except for the value of pid. pid for the parent process is the process ID of the child process. And pid for child process is 0. The process 0 is the only process which is not created via fork. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 5. • The steps followed by the kernel for fork are: • It creates a new entry in the process table. • It assigns a unique ID to the newly created process. • It makes a logical copy of the regions of the parent process. If a regions can be shared, only its reference count is incremented instead of making a physical copy of the region. • The reference counts of file table entries and inodes of the process are increased. • It turned the child process ID to the parent and 0 to the child. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 6. The algorithm fork DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 7. Fork creating a New process context DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 8. Signals • Signals inform processes of the occurrence of asynchronous events. Processes may send each other signals with the kill system call, or the kernel may send signals internally. • There are 19 signals in the System V (Release 2) UNIX system that can be classified as follows: DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 9. Signal Classifications • Signals having to do with the termination of a process, send when a process exits or when a process invokes the signal system call with the death of child parameter. • Signals having to do with process induced exceptions such as when a process accesses an address outside its virtual address space, when it attempts to write memory that is read-only (such as program text), or when it executes a privileged instruction or for various hardware errors. • Signals having to do with the unrecoverable conditions during a system call, such as running out of system resources during exec after the original address space has been released • Signals caused by an unexpected error condition during a system call, such as making a nonexistent system call (the process passed a system call number that does not correspond to a legal system call), writing a pipe that has no reader processes, or using an illegal "reference" value for the lseek system call. It would be more consistent to return an error on such system calls instead of generating a signal, but the use of signals to abort misbehaving processes is more pragmatic. • Signals originating from a process in user mode, such as when a process wishes to receive an alarm signal after a period of time, or when processes send arbitrary signals to each other with the kill system call. • Signals related to terminal interaction such as when a user hands up a terminal (or the "carrier" signal drops on such a line for any reason), or when a user presses the "break" or "delete" keys on a terminal keyboard. • Signals for tracing execution of a process. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 10. Checking and Handling Signals in the Process State Diagram DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 11. The algorithm issig DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 12. Handling Signals • The handling of signal is done through the algorithm psig, DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 13. Types of Signals DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 14. Process Groups • The system has to identify processes by "groups" in some cases, for instance, a signal might relate to all the processes which are ancestors of the login shell. The kernel uses the process group ID to identify groups of related processes that should receive a common signal for certain events. It saves the group ID in the process table. • The setpgrp system call initializes the process group number of a process and sets it equal to the value of its process ID. • grp = setpgrp(); • where grp is the new process group number. A child retains the process group number of its parent during fork. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 15. Sending Signals from Processes • Processes use the kill system call to send signals. • kill (pid, signum); • where pid identifies the set of processes to receive the signal, and signum is the signal number being sent. The following list shows the correspondence between values of pid and sets of processes. • If pid is a positive integer, the kernel sends the signal to the process with process ID pid. • If pid is 0, the kernel sends the signal to all processes in the sender's process group. • If pid is -1, the kernel sends the signal to all processes whose real user ID equals the effective user ID of the sender (real and effective user IDs are studied later). If the sending process has effective user ID of superuser, the kernel sends the signal to all processes except processes 0 and 1. • If pid is a negative integer but not -1, the kernel sends the signal to all processes in the process group equal to the absolute value of pid. • In all cases, if the sending process does not have effective user ID of superuser, or its real or effective user ID do not match the real or effective user ID of the receiving process, kill fails. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 16. Process Termination • Processes on the UNIX system exit by executing the exit system call. When a process exits, it enters the zombie state, relinquishes all of its resources, and dismantles its context except for its process table entry. • exit (status); • where status is the exit code returned to the parent. The process may call exit explicitly, but the startup routine in C calls exit after the main function returns. The kernel may call exit on receiving an uncaught signal. In such cases, the value of status is the signal number. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 17. The algorithm for exit DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 18. Awaiting Process Termination • A process can synchronize its execution with the termination of a child process by executing the wait system call. • pid = wait (stat_addr); • where pid is the process ID of the zombie child, and stat_addr is the address in user space of an integer that will contain the exit status code of the child. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 19. The algorithm for wait DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 20. Invoking Other Programs • The exec system call overlays the address space of a process with the contents of an executable file. • execve (filename, argv, envp) • where filename is name of the file being invoked, argv is a pointer to array of character pointers which are arguments to the program in the executable file, and envp is a pointer to array of character pointers which are the environment of the executed program. There are several library functions that call exec, like execl, execv, execle, and so on. All call execve eventually. The character strings in the envp array are of the form, "name=value". C programs can access the environment variables by accessing the global variable environ, initialized by the C startup routine. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 21. The algorithm for exec DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 22. The User ID of a Process • There are two user ID associated with a process, the real user ID and the effective user ID or setuid (set user ID). The real user ID identifies the user who is responsible for the running process. The effective user ID is used to assign ownership of newly created files, to check file access permissions, and to check permission to send signals to processes via the kill system call. The kernel allows a process to change its effective user ID when it execs a setuid program or when it invokes the setuid system call explicitly. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 23. • A setuid program is an executable file that has the setuid bit set in its permission mode field. When a process execs a setuid program, the kernel sets the effective user ID fields in the process table and u-area to the owner ID of the file. To distinguish the two fields, let us call the field in the process table the saved user ID. • setuid (uid); • where uid is the new user ID, and its result depends on the current value of the effective user ID. If the effective user ID of the calling process is superuser, the kernel resets the real and effective user ID fields in the process table and u-area to uid. If its not the superuser, the kernel resets the effective user ID in the u-area to uid if uid has the value of the real user ID or if it has the value of the saved user ID. Otherwise, the system call returns an error. Generally, a process inherits its real and effective user IDs from its parent during the fork system call and maintains their values across exec system calls. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 24. Changing the Size of a Process • A process can increase or decrease the size of its data region by using the brk system call. • brk (endds); • where endds becomes the value of the highest virtual address of the data region of the process (called its break value). Alternatively, a user can call • oldendds = sbrk(increment); • where increment changes the current break value by the specified number of bytes, and oldendds is the break value before the call. sbrk is a C library routine that calls brk. The kernel checks that the new process size is less than the system maximum and that the new data region does not overlap previously assigned virtual address space. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 25. Algorithm: brk DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
  • 26. •Thank you ….. DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon