SlideShare a Scribd company logo
1 of 23
Download to read offline
Presentation Topic:
Group:5,Topic:2
Kernel mode
Mode bit=0
User mode
Mode bit=1
A system call is a way for programs to interact with the
operating system. A computer program makes a system call when it
makes a request to the operating system's kernel.
System call provides the services of the operating system to the user
programs via Application Program Interface(API).
4
5
6
3
2
1Process Creation
Sleep Command
Wait Command
Sleep command using getpid
Signal Handling
Process Execution
Through appropriate system calls, such as fork or spawn,
processes used to create other processes. The process which
creates other process, is termed the parent of the other process,
while the created sub-process is termed as its child.
Fork:
• Forking refers to a function that copies the existing processes and
loads the copy and executes so that there are two identical
processes running.
Spawn:
• Spawning is the effective combination of forking + execing,
though it can be implemented with other system calls.
• A new process is created by the fork() system call. Both
processes start their execution right after the system call fork().
• Since both processes have identical but separate address
spaces, those variables initialized before the fork() call have the
same values in both address spaces.
• Since every process has its own address space, any modifications
will be independent of the others.
• Both processes (the parent and the child) continue execution at
the instruction after the fork system call, with one difference:
• The return code for the fork system call is zero for the
new(child) process. Whereas greater than zero process
identifier is returned to the parent.
System call
P r o c e s s c r e a t i o n
Algorithm for creating a process in Unix.
• STEP 1: Start the program.
• STEP 2: Declare pid as integer.
• STEP 3: Create the process using Fork command.
• STEP 4: Check pid is less than 0 then print error else if pid is equal to 0
then execute command else parent process wait for child process.
• STEP 5: Stop the program.
On Unix like operating systems, exec is a built-in command of the
Bash shell. It allows you to execute a command that completely
replaces the current process.
As a new process is not created, the process ID (PID) does not
change across an execute.
The first Unix shell was the Thompson shell, sh, written by ken-
Thompson at Bell Laboratory.
But the most widely distributed and influential of the early Unix
shells were the Bourne shell.
EXECUTING A COMMAND
(Using Shell)
First open the terminal.
write command given
below:
cat /etc/shells
This command shows the
shell type which your OS
support.
Now to know where bash
is located in yours system
write command:
which bash
echo “Program for
executing UNIX command
using shell programming”
echo “Welcome”
ps
exec wc “wc.sh”
echo “Program for
executing
UNIX command using
shell
programming”
echo “Welcome”
ps
exec wc
cs_2254_lab_manual.pdf”
A parent process usually needs to synchronize its actions by
waiting until the child process has either stopped or
terminated its actions.
The wait() system call allows the parent process to suspend
its activities until one of these actions has occurred.
• If the calling process does not have any child associated
with it, wait will return immediately with a value of -1.
• If any child processes are still active, the calling process
will suspend its activity until a child process terminates.
 Step 1: Start the execution.
 Step 2: Create process using fork and assign it to a variable.
 Step 3: Check for the condition pid is equal to 0.
 Step 4: If it is not a parent process has to wait until the child process.
 Step 5: If it is not a parent process has to wait until the child
teriminate.
 Step 6: Stop the execution.
SLEEP
SLEEP SYSTEM CALL
• On Unix-like operating systems, the sleep system
call is used to delay a process of system for a
specified amount of time.
• It takes time in seconds by default but a small
suffix(s, m, h, d) can be added at the end to
convert it into any other format.
SLEEP
• On Windows, the Sleep() function takes a
single parameter of the number of
milliseconds to sleep.
C examples
• In Windows OS:
Sleep(2*1000); // Sleep for 2 seconds
• In Unix:
sleep(2); // Sleep for 2 seconds
SLEEP
USING GETPID
SLEEP SYSTEM CALL
(using getpid)
• As we already know about sleep system call now we
have to discuss it with getpid and getppid commands.
• Both getppid() and getpid() are built-in functions.
Getppid():
Return type:
Getppid() returns the process ID of the parent of the calling
process.
SLEEP USING GETPID
For example:
when fork() function is use and the parent process still
exists at the time of the getppid function call, this
function returns the process ID of the parent process.
• Getpid() :
Returns the process ID of the calling process.
getpid() returns the process ID of the current process.
SIGNAL
HANDLING
Signal Handling
• A signal is a software interrupt delivered to a
process.
• The operating system uses signals to report
exceptional situations to an executing program.
• If you anticipate an event that causes signals, you
can define a handler function and tell the
operating system to run it when that particular
type of signal arrives.
#!/bin/bash
echo “program for performing
kill operation”
ps
echo “enter the pid”
read “pid”
echo “finished”
Thanks'

More Related Content

What's hot

Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process SchedulingDamian T. Gordon
 
Linux process management
Linux process managementLinux process management
Linux process managementRaghu nath
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process managementArnav Chowdhury
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipeliningMazin Alwaaly
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating SystemRaj Mohan
 
System call (Fork +Exec)
System call (Fork +Exec)System call (Fork +Exec)
System call (Fork +Exec)Amit Ghosh
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInteX Research Lab
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentationusmankiyani1
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43myrajendra
 

What's hot (20)

Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
 
Linux process management
Linux process managementLinux process management
Linux process management
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Process of operating system
Process of operating systemProcess of operating system
Process of operating system
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Process scheduling linux
Process scheduling linuxProcess scheduling linux
Process scheduling linux
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
System call (Fork +Exec)
System call (Fork +Exec)System call (Fork +Exec)
System call (Fork +Exec)
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
process control block
process control blockprocess control block
process control block
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
 
Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Deadlock Prevention
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
 
RTOS - Real Time Operating Systems
RTOS - Real Time Operating SystemsRTOS - Real Time Operating Systems
RTOS - Real Time Operating Systems
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
Process threads operating system.
Process threads operating system.Process threads operating system.
Process threads operating system.
 
Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 

Similar to Kernel Mode, User Mode, System Calls, Process Creation & Execution

Similar to Kernel Mode, User Mode, System Calls, Process Creation & Execution (20)

Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
4) system call acts as an interface to the OS services.A system call.pdf
4) system call acts as an interface to the OS services.A system call.pdf4) system call acts as an interface to the OS services.A system call.pdf
4) system call acts as an interface to the OS services.A system call.pdf
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
System Calls - Introduction
System Calls - IntroductionSystem Calls - Introduction
System Calls - Introduction
 
What is-a-computer-process-os
What is-a-computer-process-osWhat is-a-computer-process-os
What is-a-computer-process-os
 
UNIX Notes
UNIX NotesUNIX Notes
UNIX Notes
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxWeek 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docx
 
Experimentos lab
Experimentos labExperimentos lab
Experimentos lab
 
Unix Shell and System Boot Process
Unix Shell and System Boot ProcessUnix Shell and System Boot Process
Unix Shell and System Boot Process
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
 
Os presentation process
Os presentation processOs presentation process
Os presentation process
 
Linux container internals
Linux container internalsLinux container internals
Linux container internals
 
Clustering manual
Clustering manualClustering manual
Clustering manual
 
Os notes
Os notesOs notes
Os notes
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
Os lectures
Os lecturesOs lectures
Os lectures
 
Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
 
Chapter 02 modified
Chapter 02 modifiedChapter 02 modified
Chapter 02 modified
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Kernel Mode, User Mode, System Calls, Process Creation & Execution

  • 2. Kernel mode Mode bit=0 User mode Mode bit=1 A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system's kernel. System call provides the services of the operating system to the user programs via Application Program Interface(API).
  • 3. 4 5 6 3 2 1Process Creation Sleep Command Wait Command Sleep command using getpid Signal Handling Process Execution
  • 4. Through appropriate system calls, such as fork or spawn, processes used to create other processes. The process which creates other process, is termed the parent of the other process, while the created sub-process is termed as its child. Fork: • Forking refers to a function that copies the existing processes and loads the copy and executes so that there are two identical processes running. Spawn: • Spawning is the effective combination of forking + execing, though it can be implemented with other system calls.
  • 5. • A new process is created by the fork() system call. Both processes start their execution right after the system call fork(). • Since both processes have identical but separate address spaces, those variables initialized before the fork() call have the same values in both address spaces. • Since every process has its own address space, any modifications will be independent of the others. • Both processes (the parent and the child) continue execution at the instruction after the fork system call, with one difference: • The return code for the fork system call is zero for the new(child) process. Whereas greater than zero process identifier is returned to the parent.
  • 6. System call P r o c e s s c r e a t i o n Algorithm for creating a process in Unix. • STEP 1: Start the program. • STEP 2: Declare pid as integer. • STEP 3: Create the process using Fork command. • STEP 4: Check pid is less than 0 then print error else if pid is equal to 0 then execute command else parent process wait for child process. • STEP 5: Stop the program.
  • 7.
  • 8. On Unix like operating systems, exec is a built-in command of the Bash shell. It allows you to execute a command that completely replaces the current process. As a new process is not created, the process ID (PID) does not change across an execute. The first Unix shell was the Thompson shell, sh, written by ken- Thompson at Bell Laboratory. But the most widely distributed and influential of the early Unix shells were the Bourne shell.
  • 9. EXECUTING A COMMAND (Using Shell) First open the terminal. write command given below: cat /etc/shells This command shows the shell type which your OS support. Now to know where bash is located in yours system write command: which bash
  • 10. echo “Program for executing UNIX command using shell programming” echo “Welcome” ps exec wc “wc.sh” echo “Program for executing UNIX command using shell programming” echo “Welcome” ps exec wc cs_2254_lab_manual.pdf”
  • 11. A parent process usually needs to synchronize its actions by waiting until the child process has either stopped or terminated its actions. The wait() system call allows the parent process to suspend its activities until one of these actions has occurred. • If the calling process does not have any child associated with it, wait will return immediately with a value of -1. • If any child processes are still active, the calling process will suspend its activity until a child process terminates.
  • 12.  Step 1: Start the execution.  Step 2: Create process using fork and assign it to a variable.  Step 3: Check for the condition pid is equal to 0.  Step 4: If it is not a parent process has to wait until the child process.  Step 5: If it is not a parent process has to wait until the child teriminate.  Step 6: Stop the execution.
  • 13.
  • 14. SLEEP SLEEP SYSTEM CALL • On Unix-like operating systems, the sleep system call is used to delay a process of system for a specified amount of time. • It takes time in seconds by default but a small suffix(s, m, h, d) can be added at the end to convert it into any other format.
  • 15. SLEEP • On Windows, the Sleep() function takes a single parameter of the number of milliseconds to sleep. C examples • In Windows OS: Sleep(2*1000); // Sleep for 2 seconds • In Unix: sleep(2); // Sleep for 2 seconds
  • 16.
  • 17. SLEEP USING GETPID SLEEP SYSTEM CALL (using getpid) • As we already know about sleep system call now we have to discuss it with getpid and getppid commands. • Both getppid() and getpid() are built-in functions. Getppid(): Return type: Getppid() returns the process ID of the parent of the calling process.
  • 18. SLEEP USING GETPID For example: when fork() function is use and the parent process still exists at the time of the getppid function call, this function returns the process ID of the parent process. • Getpid() : Returns the process ID of the calling process. getpid() returns the process ID of the current process.
  • 19.
  • 20.
  • 21. SIGNAL HANDLING Signal Handling • A signal is a software interrupt delivered to a process. • The operating system uses signals to report exceptional situations to an executing program. • If you anticipate an event that causes signals, you can define a handler function and tell the operating system to run it when that particular type of signal arrives.
  • 22. #!/bin/bash echo “program for performing kill operation” ps echo “enter the pid” read “pid” echo “finished”