SlideShare a Scribd company logo
OPERATING SYSTEMS Lab [BCS303]
Department of CSE- Data Science
PRACTICAL COMPONENT OF IPCC(May cover all / major modules)
1. Develop a c program to implement the Process system calls (fork (), exec(),
wait(), create process, terminate process)
2. Simulate the following CPU scheduling algorithms to find turnaround time
and waiting time
a) FCFS b) SJF c) Round Robin d) Priority.
3. Develop a C program to simulate producer-consumer problem using
semaphores.
4. Develop a C program which demonstrates interprocess communication between
a reader process and a writer process. Use mkfifo, open, read, write and
close APIs in your program.
Department of CSE- Data Science
PRACTICAL COMPONENT OF IPCC contd…
5. Develop a C program to simulate Bankers Algorithm for DeadLock
Avoidance.
6. Develop a C program to simulate the following contiguous memory
allocation Techniques:
a) Worst fit b) Best fit c) First fit.
7. Develop a C program to simulate page replacement algorithms:
a) FIFO b) LRU
8. Simulate following File Organization Techniques
a) Single level directory b) Two level directory
Department of CSE- Data Science
PRACTICAL COMPONENT OF IPCC contd…
9. Develop a C program to simulate the Linked file allocation strategies.
10. Develop a C program to simulate SCAN disk scheduling algorithm.
Department of CSE- Data Science
Program 1: Develop a c program to implement the Process system calls (fork (),
exec(), wait(), create process, terminate process)
System Calls in Operating System
 A system call is a way for a user program to interface with the operating system.
 A system call is an interface between a program running in user space and
the operating system (OS).
 Application programs use system calls to request services and functionalities
from the OS's kernel.
Department of CSE- Data Science
 System calls are required in the following situations
- If a file system requires the creation or deletion of files. Reading and
writing from files also require a system call.
- Creation and management of new processes.
- Network connections also require system calls. This includes sending
and receiving packets.
- Access to a hardware devices such as a printer, scanner etc. requires a
system call
Department of CSE- Data Science
Department of CSE- Data Science
Fig: Execution of the system call
Department of CSE- Data Science
Department of CSE- Data Science
fork()
 Used to create new processes.
 The new process consists of a copy of the address space of the original
process.
 The value of process id for the child process is zero, whereas the value of
process id for the parent is an integer value greater than zero.
Department of CSE- Data Science
 Algorithm
1. Declare two variables pid and childid.
2. Get the childid value using system call fork().
3. If childid > zero then
print as “i am in the parent process”
retrieve process ID (PID) and its parent process ID (PPID) using getpid()
and getppid()
else
print “ i am in child process”
retrieve process ID (PID) and its parent process ID (PPID) using getpid()
and getppid()
Department of CSE- Data Science
getpid() Method
 The PID of the calling process is returned by the getpid() method, which is a
distinctive identification given to each active process in the system.
 Note: Every time you execute the program, the actual PID value (for example, 1234)
will change because it depends on the system and the status of the running
processes.
getppid() Method
 The PID of the calling process's parent process is returned by the getppid() method.
 The PID of the process that initiated the current process is thus retrieved.
 Note: The actual PPID value (for instance, 5678) will change depending on the
system and the active parent process, much like with the getpid() function.
Department of CSE- Data Science
Department of CSE- Data Science
Wait()
 The parent waits for the child process to complete using the wait system call.
The wait system call returns the process identifier of a terminated child, so that
the parent can tell which of its possibly many children has terminated.
 Syntax: wait (NULL);
exit ( )
 A process terminates when it finishes executing its final statement and asks the
operating system to delete it by using the exit system call.
 At that point, the process may return data (output) to its parent process (via the
wait system call).
 Syntax: exit (0);
Department of CSE- Data Science
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int main( )
{
int i, pid;
pid=fork( );
if(pid== -1)
{
printf("fork failed");
exit(0);
}
else if(pid==0)
{
printf("n Child process starts");
for(i=0; i<5; i++)
{
printf("n Child process %d is called", i);
}
printf("n Child process ends");
}
else
{
wait(0);
printf("n Parent process ends");
}
exit(0);
}
Department of CSE- Data Science
exec
 The exec family of functions replaces the current running process with a
new process.
 It can be used to run a C program by using another C program. It comes
under the header file unistd.h.
 There are many members in the exec family
i. execvp()
ii. execv()
iii. execlp()
iv. execl()
Department of CSE- Data Science
execv()
 replaces the currently executing program with a newly loaded program image.
 This occurs within one process; the process id is unchanged.
 The pathname of the program to run is passed as program.
#include<stdio.h>
#include<sys/types.h>
main(int argc,char *argv[])
{
printf("before execvn");
execv("/bin/ls",argv);
printf("after execvn");
}
Ad

More Related Content

Similar to Operating systems Lab program: to develop C program to implement process management system calls (20)

Lect3 process
Lect3 processLect3 process
Lect3 process
santosh rao
 
OSLec 4& 5(Processesinoperatingsystem).ppt
OSLec 4& 5(Processesinoperatingsystem).pptOSLec 4& 5(Processesinoperatingsystem).ppt
OSLec 4& 5(Processesinoperatingsystem).ppt
ssusere16bd9
 
Process management
Process managementProcess management
Process management
Birju Tank
 
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
 
LP-Unit3.docx
LP-Unit3.docxLP-Unit3.docx
LP-Unit3.docx
SeetharamNageshAppe1
 
process creation OS
process creation OSprocess creation OS
process creation OS
Kiran Kumar Thota
 
OS Lab 05.pdfdxsffffffffffxxxxgsssssfdgg
OS Lab 05.pdfdxsffffffffffxxxxgsssssfdggOS Lab 05.pdfdxsffffffffffxxxxgsssssfdgg
OS Lab 05.pdfdxsffffffffffxxxxgsssssfdgg
SamraNawabi
 
operating system question bank
operating system question bankoperating system question bank
operating system question bank
rajatdeep kaur
 
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
Kathirvel Ayyaswamy
 
Chapter3_ProcessConcept-Operation_on_Processes.pptx
Chapter3_ProcessConcept-Operation_on_Processes.pptxChapter3_ProcessConcept-Operation_on_Processes.pptx
Chapter3_ProcessConcept-Operation_on_Processes.pptx
SaraZara10
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
Mohammed Farrag
 
Process threads operating system.
Process threads operating system.Process threads operating system.
Process threads operating system.
Reham Maher El-Safarini
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
Ziyauddin Shaik
 
Linux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and SignalsLinux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and Signals
RashidFaridChishti
 
Os notes
Os notesOs notes
Os notes
LakshmiSarvani6
 
A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark
Anyscale
 
Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0
Anyscale
 
Virus lab
Virus labVirus lab
Virus lab
kunalashutosh92
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
ashukiller7
 
OSLec 4& 5(Processesinoperatingsystem).ppt
OSLec 4& 5(Processesinoperatingsystem).pptOSLec 4& 5(Processesinoperatingsystem).ppt
OSLec 4& 5(Processesinoperatingsystem).ppt
ssusere16bd9
 
Process management
Process managementProcess management
Process management
Birju Tank
 
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
 
OS Lab 05.pdfdxsffffffffffxxxxgsssssfdgg
OS Lab 05.pdfdxsffffffffffxxxxgsssssfdggOS Lab 05.pdfdxsffffffffffxxxxgsssssfdgg
OS Lab 05.pdfdxsffffffffffxxxxgsssssfdgg
SamraNawabi
 
operating system question bank
operating system question bankoperating system question bank
operating system question bank
rajatdeep kaur
 
Chapter3_ProcessConcept-Operation_on_Processes.pptx
Chapter3_ProcessConcept-Operation_on_Processes.pptxChapter3_ProcessConcept-Operation_on_Processes.pptx
Chapter3_ProcessConcept-Operation_on_Processes.pptx
SaraZara10
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
Mohammed Farrag
 
Linux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and SignalsLinux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and Signals
RashidFaridChishti
 
A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark
Anyscale
 
Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0
Anyscale
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
ashukiller7
 

More from ambikavenkatesh2 (19)

CN(BCS502) Module-4 _Transport Layer.pptx
CN(BCS502) Module-4 _Transport Layer.pptxCN(BCS502) Module-4 _Transport Layer.pptx
CN(BCS502) Module-4 _Transport Layer.pptx
ambikavenkatesh2
 
Module-3 Deadlocks.pptx BCS303 Operating system
Module-3 Deadlocks.pptx BCS303 Operating systemModule-3 Deadlocks.pptx BCS303 Operating system
Module-3 Deadlocks.pptx BCS303 Operating system
ambikavenkatesh2
 
V semester, computer networks BCS502 Module-2_DataLinkLayer
V semester, computer networks BCS502 Module-2_DataLinkLayerV semester, computer networks BCS502 Module-2_DataLinkLayer
V semester, computer networks BCS502 Module-2_DataLinkLayer
ambikavenkatesh2
 
Module-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptxModule-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptx
ambikavenkatesh2
 
computer networks lab program Bellman Ford.pptx
computer networks lab program Bellman Ford.pptxcomputer networks lab program Bellman Ford.pptx
computer networks lab program Bellman Ford.pptx
ambikavenkatesh2
 
Module-1.pptx Computer Networks BCS502 module-1 ppt
Module-1.pptx Computer Networks BCS502 module-1 pptModule-1.pptx Computer Networks BCS502 module-1 ppt
Module-1.pptx Computer Networks BCS502 module-1 ppt
ambikavenkatesh2
 
Module-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptxModule-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptx
ambikavenkatesh2
 
Concurrency Control in Databases.Database management systems
Concurrency Control in Databases.Database management systemsConcurrency Control in Databases.Database management systems
Concurrency Control in Databases.Database management systems
ambikavenkatesh2
 
MODULE-1_Operating System Services - ppt
MODULE-1_Operating System Services - pptMODULE-1_Operating System Services - ppt
MODULE-1_Operating System Services - ppt
ambikavenkatesh2
 
Module1_Decision Support and Business Intelligence.pptx
Module1_Decision Support and Business Intelligence.pptxModule1_Decision Support and Business Intelligence.pptx
Module1_Decision Support and Business Intelligence.pptx
ambikavenkatesh2
 
Transactions and concurrency control mechanisms in database management system
Transactions and concurrency control mechanisms in  database management systemTransactions and concurrency control mechanisms in  database management system
Transactions and concurrency control mechanisms in database management system
ambikavenkatesh2
 
data base management system notes on concurrency control
data base management system notes on concurrency controldata base management system notes on concurrency control
data base management system notes on concurrency control
ambikavenkatesh2
 
Unit1_Fundamentals of Information Technlogy
Unit1_Fundamentals of Information TechnlogyUnit1_Fundamentals of Information Technlogy
Unit1_Fundamentals of Information Technlogy
ambikavenkatesh2
 
Module-1 Data base management systems chap1-Introduction to database.pptx
Module-1 Data base management systems chap1-Introduction to database.pptxModule-1 Data base management systems chap1-Introduction to database.pptx
Module-1 Data base management systems chap1-Introduction to database.pptx
ambikavenkatesh2
 
object oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoMobject oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoM
ambikavenkatesh2
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysore
ambikavenkatesh2
 
Tableau.pptx
Tableau.pptxTableau.pptx
Tableau.pptx
ambikavenkatesh2
 
ICT.pptx
ICT.pptxICT.pptx
ICT.pptx
ambikavenkatesh2
 
unit-1_Introduction to e-commerce.pptx
unit-1_Introduction to e-commerce.pptxunit-1_Introduction to e-commerce.pptx
unit-1_Introduction to e-commerce.pptx
ambikavenkatesh2
 
CN(BCS502) Module-4 _Transport Layer.pptx
CN(BCS502) Module-4 _Transport Layer.pptxCN(BCS502) Module-4 _Transport Layer.pptx
CN(BCS502) Module-4 _Transport Layer.pptx
ambikavenkatesh2
 
Module-3 Deadlocks.pptx BCS303 Operating system
Module-3 Deadlocks.pptx BCS303 Operating systemModule-3 Deadlocks.pptx BCS303 Operating system
Module-3 Deadlocks.pptx BCS303 Operating system
ambikavenkatesh2
 
V semester, computer networks BCS502 Module-2_DataLinkLayer
V semester, computer networks BCS502 Module-2_DataLinkLayerV semester, computer networks BCS502 Module-2_DataLinkLayer
V semester, computer networks BCS502 Module-2_DataLinkLayer
ambikavenkatesh2
 
Module-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptxModule-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptx
ambikavenkatesh2
 
computer networks lab program Bellman Ford.pptx
computer networks lab program Bellman Ford.pptxcomputer networks lab program Bellman Ford.pptx
computer networks lab program Bellman Ford.pptx
ambikavenkatesh2
 
Module-1.pptx Computer Networks BCS502 module-1 ppt
Module-1.pptx Computer Networks BCS502 module-1 pptModule-1.pptx Computer Networks BCS502 module-1 ppt
Module-1.pptx Computer Networks BCS502 module-1 ppt
ambikavenkatesh2
 
Module-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptxModule-1_Introduction to Data Communications.pptx
Module-1_Introduction to Data Communications.pptx
ambikavenkatesh2
 
Concurrency Control in Databases.Database management systems
Concurrency Control in Databases.Database management systemsConcurrency Control in Databases.Database management systems
Concurrency Control in Databases.Database management systems
ambikavenkatesh2
 
MODULE-1_Operating System Services - ppt
MODULE-1_Operating System Services - pptMODULE-1_Operating System Services - ppt
MODULE-1_Operating System Services - ppt
ambikavenkatesh2
 
Module1_Decision Support and Business Intelligence.pptx
Module1_Decision Support and Business Intelligence.pptxModule1_Decision Support and Business Intelligence.pptx
Module1_Decision Support and Business Intelligence.pptx
ambikavenkatesh2
 
Transactions and concurrency control mechanisms in database management system
Transactions and concurrency control mechanisms in  database management systemTransactions and concurrency control mechanisms in  database management system
Transactions and concurrency control mechanisms in database management system
ambikavenkatesh2
 
data base management system notes on concurrency control
data base management system notes on concurrency controldata base management system notes on concurrency control
data base management system notes on concurrency control
ambikavenkatesh2
 
Unit1_Fundamentals of Information Technlogy
Unit1_Fundamentals of Information TechnlogyUnit1_Fundamentals of Information Technlogy
Unit1_Fundamentals of Information Technlogy
ambikavenkatesh2
 
Module-1 Data base management systems chap1-Introduction to database.pptx
Module-1 Data base management systems chap1-Introduction to database.pptxModule-1 Data base management systems chap1-Introduction to database.pptx
Module-1 Data base management systems chap1-Introduction to database.pptx
ambikavenkatesh2
 
object oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoMobject oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoM
ambikavenkatesh2
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysore
ambikavenkatesh2
 
unit-1_Introduction to e-commerce.pptx
unit-1_Introduction to e-commerce.pptxunit-1_Introduction to e-commerce.pptx
unit-1_Introduction to e-commerce.pptx
ambikavenkatesh2
 
Ad

Recently uploaded (20)

Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Journal of Soft Computing in Civil Engineering
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
Ad

Operating systems Lab program: to develop C program to implement process management system calls

  • 1. OPERATING SYSTEMS Lab [BCS303] Department of CSE- Data Science
  • 2. PRACTICAL COMPONENT OF IPCC(May cover all / major modules) 1. Develop a c program to implement the Process system calls (fork (), exec(), wait(), create process, terminate process) 2. Simulate the following CPU scheduling algorithms to find turnaround time and waiting time a) FCFS b) SJF c) Round Robin d) Priority. 3. Develop a C program to simulate producer-consumer problem using semaphores. 4. Develop a C program which demonstrates interprocess communication between a reader process and a writer process. Use mkfifo, open, read, write and close APIs in your program. Department of CSE- Data Science
  • 3. PRACTICAL COMPONENT OF IPCC contd… 5. Develop a C program to simulate Bankers Algorithm for DeadLock Avoidance. 6. Develop a C program to simulate the following contiguous memory allocation Techniques: a) Worst fit b) Best fit c) First fit. 7. Develop a C program to simulate page replacement algorithms: a) FIFO b) LRU 8. Simulate following File Organization Techniques a) Single level directory b) Two level directory Department of CSE- Data Science
  • 4. PRACTICAL COMPONENT OF IPCC contd… 9. Develop a C program to simulate the Linked file allocation strategies. 10. Develop a C program to simulate SCAN disk scheduling algorithm. Department of CSE- Data Science
  • 5. Program 1: Develop a c program to implement the Process system calls (fork (), exec(), wait(), create process, terminate process) System Calls in Operating System  A system call is a way for a user program to interface with the operating system.  A system call is an interface between a program running in user space and the operating system (OS).  Application programs use system calls to request services and functionalities from the OS's kernel. Department of CSE- Data Science
  • 6.  System calls are required in the following situations - If a file system requires the creation or deletion of files. Reading and writing from files also require a system call. - Creation and management of new processes. - Network connections also require system calls. This includes sending and receiving packets. - Access to a hardware devices such as a printer, scanner etc. requires a system call Department of CSE- Data Science
  • 7. Department of CSE- Data Science Fig: Execution of the system call
  • 8. Department of CSE- Data Science
  • 9. Department of CSE- Data Science fork()  Used to create new processes.  The new process consists of a copy of the address space of the original process.  The value of process id for the child process is zero, whereas the value of process id for the parent is an integer value greater than zero.
  • 10. Department of CSE- Data Science  Algorithm 1. Declare two variables pid and childid. 2. Get the childid value using system call fork(). 3. If childid > zero then print as “i am in the parent process” retrieve process ID (PID) and its parent process ID (PPID) using getpid() and getppid() else print “ i am in child process” retrieve process ID (PID) and its parent process ID (PPID) using getpid() and getppid()
  • 11. Department of CSE- Data Science getpid() Method  The PID of the calling process is returned by the getpid() method, which is a distinctive identification given to each active process in the system.  Note: Every time you execute the program, the actual PID value (for example, 1234) will change because it depends on the system and the status of the running processes. getppid() Method  The PID of the calling process's parent process is returned by the getppid() method.  The PID of the process that initiated the current process is thus retrieved.  Note: The actual PPID value (for instance, 5678) will change depending on the system and the active parent process, much like with the getpid() function.
  • 12. Department of CSE- Data Science
  • 13. Department of CSE- Data Science Wait()  The parent waits for the child process to complete using the wait system call. The wait system call returns the process identifier of a terminated child, so that the parent can tell which of its possibly many children has terminated.  Syntax: wait (NULL); exit ( )  A process terminates when it finishes executing its final statement and asks the operating system to delete it by using the exit system call.  At that point, the process may return data (output) to its parent process (via the wait system call).  Syntax: exit (0);
  • 14. Department of CSE- Data Science #include<stdio.h> #include<unistd.h> #include<stdlib.h> int main( ) { int i, pid; pid=fork( ); if(pid== -1) { printf("fork failed"); exit(0); } else if(pid==0) { printf("n Child process starts"); for(i=0; i<5; i++) { printf("n Child process %d is called", i); } printf("n Child process ends"); } else { wait(0); printf("n Parent process ends"); } exit(0); }
  • 15. Department of CSE- Data Science exec  The exec family of functions replaces the current running process with a new process.  It can be used to run a C program by using another C program. It comes under the header file unistd.h.  There are many members in the exec family i. execvp() ii. execv() iii. execlp() iv. execl()
  • 16. Department of CSE- Data Science execv()  replaces the currently executing program with a newly loaded program image.  This occurs within one process; the process id is unchanged.  The pathname of the program to run is passed as program. #include<stdio.h> #include<sys/types.h> main(int argc,char *argv[]) { printf("before execvn"); execv("/bin/ls",argv); printf("after execvn"); }
  翻译: