SlideShare a Scribd company logo
OPERATING SYSTEMS
System Calls
INTRODUCTION
Know it!
In computing, a system call is a programmatic way in
which a computer program requests a service from the
kernel of the operating system it is executed on.
A system call allows 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.
All programs needing resources must use system calls.
Example
For example, if we need to write a program code to
read data from one file, copy that data into another file.
The first information that the program requires is the
name of the two files, the input and output files.
In an interactive system, this type of program
execution requires some system calls by OS.
First call is to write a prompting message on the
screen
Second, to read from the keyboard, the characters
which define the two files.
Kernel Mode Vs User Mode
Some system calls -
Some use cases
Reading and writing from files demand system calls.
If a file system wants to create or delete files, system
calls are required.
System calls are used for the creation and
management of new processes.
Network connections need system calls for sending
and receiving packets.
Access to hardware devices like scanner, and printer,
need a system call.
wait()
In some systems, a process needs to wait for another
process to complete its execution. This type of
situation occurs when a parent process creates a child
process, and the execution of the parent process
remains suspended until its child process executes.
The suspension of the parent process automatically
occurs with a wait() system call. When the child
process ends execution, the control moves back to the
parent process.
fork()
Processes use this system call to create processes
that are a copy of themselves.
With the help of this system Call parent process
creates a child process, and the execution of the parent
process will be suspended till the child process
executes.
Example
#include<stdio.h>
#include<unistd.h>
int main(){
printf("PID = %dn", getpid());
return 0;
}
getid()
Getpid() is the function used to get the process ID of
the process that calls that function. The PID for the
initial process is 1, and then each new process is
assigned a new Id. It is a simple approach to getting
the PID.
Example
#include<stdio.h>
#include<unistd.h>
int main(){
fork();
printf("PID = %dn", getpid());
return 0;
}
fork() system call is used to create a separate, duplicate process)
Example
#include<stdio.h>
#include<unistd.h>
int main(){
fork();
fork();
fork();
printf("PID = %dn", getpid());
return 0;
}
Prints 8 times!!
P1 P2 P6
P4
P3
P5
P8 P7
Example
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include <sys/wait.h>
int main(){
int fd[2],n;
char buffer[100];
pid_t p;
pipe(fd);
p = fork();
}
if(p>0){
close(fd[0]);
printf("Passing value to child!n");
write(fd[1],"Hello my child!!",15);
printf("n");
wait(NULL);
}
else{
close(fd[1]);
n = read(fd[0], buffer, 100);
write(1,buffer,n);
}
STEPS IN SYSTEM
CALLS
In steps 1-3, the calling program pushes the parameters onto the stack. The first and third
parameters are called by value, but the second one is called by its address as denoted by the
& symbol.
In step 4, the actual call to the library procedure is made. This instruction is the normal
procedure call instruction used to call all procedures.
In step 5, the library procedure places the system call number in a place where the operating
system expects it, such as a register.
In step 6, the library procedure executes a TRAP instruction to switch from user mode to
kernel mode and start execution at a fixed address within the kernel.
In step 7, the kernel examines the system call number and then dispatches it to the correct
system call handler. This correct number is given in the table of system call handlers by
pointers referenced at the system call number.
In step 8, the system call handler runs.
In step 9, the operation is completed, and the user is given back control once the TRAP
instruction is set.
In step 10, this procedure returns to the user program, like how all normal library procedures
do.
In step 11, the operating system has to clear the stack, so it increments it enough so that it is
empty.
Practice
#include<stdio.h>
#include<unistd.h>
int main(){
fork();
fork();
fork();
fork();
printf("PID = %dn", getpid());
return 0;
}
How many times would the printf statement be executed??
Practice
#include<stdio.h>
#include<unistd.h>
int main(){
fork();
fork();
fork();
fork();
printf("PID = %dn", getpid());
return 0;
}
16 process | 15 child process | 1 root process
Thank you!!

More Related Content

Similar to System Calls - Introduction

Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docxLab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
festockton
 
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESOPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
priyasoundar
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
Mohammed Farrag
 
computer notes - Inter process communication
computer notes - Inter process communicationcomputer notes - Inter process communication
computer notes - Inter process communication
ecomputernotes
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process Management
Veejeya Kumbhar
 
LINUX Device Drivers
LINUX Device DriversLINUX Device Drivers
LINUX Device Drivers
Partha Bhattacharya
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxWeek 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docx
melbruce90096
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
Mazenetsolution
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
ashukiller7
 
Systemcall
SystemcallSystemcall
Systemcall
Mahesh Shitole
 
Systemcall1
Systemcall1Systemcall1
Systemcall1
pavimalpani
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
Rakibul Rakib
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
Ziyauddin Shaik
 
Implementation of Kernel API
Implementation of Kernel APIImplementation of Kernel API
Implementation of Kernel API
khushi74
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2
HectorFabianPintoOsp
 
ECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/SnaptutorialECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/Snaptutorial
pinck2380
 
ECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/SnaptutorialECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/Snaptutorial
pinck200
 
process creation OS
process creation OSprocess creation OS
process creation OS
Kiran Kumar Thota
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
KumarMit2
 
Ecet 360 Massive Success / snaptutorial.com
Ecet 360 Massive Success / snaptutorial.comEcet 360 Massive Success / snaptutorial.com
Ecet 360 Massive Success / snaptutorial.com
HarrisGeorgx
 

Similar to System Calls - Introduction (20)

Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docxLab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
 
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESOPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
 
computer notes - Inter process communication
computer notes - Inter process communicationcomputer notes - Inter process communication
computer notes - Inter process communication
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process Management
 
LINUX Device Drivers
LINUX Device DriversLINUX Device Drivers
LINUX Device Drivers
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxWeek 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docx
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
 
Systemcall
SystemcallSystemcall
Systemcall
 
Systemcall1
Systemcall1Systemcall1
Systemcall1
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
Implementation of Kernel API
Implementation of Kernel APIImplementation of Kernel API
Implementation of Kernel API
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2
 
ECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/SnaptutorialECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/Snaptutorial
 
ECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/SnaptutorialECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/Snaptutorial
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
 
Ecet 360 Massive Success / snaptutorial.com
Ecet 360 Massive Success / snaptutorial.comEcet 360 Massive Success / snaptutorial.com
Ecet 360 Massive Success / snaptutorial.com
 

More from To Sum It Up

Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1
To Sum It Up
 
Artificial intelligence ( AI ) | Guide
Artificial intelligence ( AI )  |  GuideArtificial intelligence ( AI )  |  Guide
Artificial intelligence ( AI ) | Guide
To Sum It Up
 
On Page SEO (Search Engine Optimization)
On Page SEO (Search Engine Optimization)On Page SEO (Search Engine Optimization)
On Page SEO (Search Engine Optimization)
To Sum It Up
 
Prompt Engineering | Beginner's Guide - For You
Prompt Engineering | Beginner's Guide - For YouPrompt Engineering | Beginner's Guide - For You
Prompt Engineering | Beginner's Guide - For You
To Sum It Up
 
Natural Language Processing (NLP) | Basics
Natural Language Processing (NLP) | BasicsNatural Language Processing (NLP) | Basics
Natural Language Processing (NLP) | Basics
To Sum It Up
 
It's Machine Learning Basics -- For You!
It's Machine Learning Basics -- For You!It's Machine Learning Basics -- For You!
It's Machine Learning Basics -- For You!
To Sum It Up
 
Polymorphism in Python
Polymorphism in PythonPolymorphism in Python
Polymorphism in Python
To Sum It Up
 
DSA Question Bank
DSA Question BankDSA Question Bank
DSA Question Bank
To Sum It Up
 
Web API - Overview
Web API - OverviewWeb API - Overview
Web API - Overview
To Sum It Up
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
To Sum It Up
 
HTML Overview
HTML OverviewHTML Overview
HTML Overview
To Sum It Up
 
EM Algorithm
EM AlgorithmEM Algorithm
EM Algorithm
To Sum It Up
 
User story mapping
User story mappingUser story mapping
User story mapping
To Sum It Up
 
User stories
User storiesUser stories
User stories
To Sum It Up
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
To Sum It Up
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1 Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
To Sum It Up
 
Quality Circle | Case Study on Self Esteem | Team Opus Geeks.pdf
Quality Circle | Case Study on Self Esteem | Team Opus Geeks.pdfQuality Circle | Case Study on Self Esteem | Team Opus Geeks.pdf
Quality Circle | Case Study on Self Esteem | Team Opus Geeks.pdf
To Sum It Up
 
Multimedia Content and Content Acquisition
Multimedia Content and Content AcquisitionMultimedia Content and Content Acquisition
Multimedia Content and Content Acquisition
To Sum It Up
 
PHP Arrays_Introduction
PHP Arrays_IntroductionPHP Arrays_Introduction
PHP Arrays_Introduction
To Sum It Up
 
Leadership
LeadershipLeadership
Leadership
To Sum It Up
 

More from To Sum It Up (20)

Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1
 
Artificial intelligence ( AI ) | Guide
Artificial intelligence ( AI )  |  GuideArtificial intelligence ( AI )  |  Guide
Artificial intelligence ( AI ) | Guide
 
On Page SEO (Search Engine Optimization)
On Page SEO (Search Engine Optimization)On Page SEO (Search Engine Optimization)
On Page SEO (Search Engine Optimization)
 
Prompt Engineering | Beginner's Guide - For You
Prompt Engineering | Beginner's Guide - For YouPrompt Engineering | Beginner's Guide - For You
Prompt Engineering | Beginner's Guide - For You
 
Natural Language Processing (NLP) | Basics
Natural Language Processing (NLP) | BasicsNatural Language Processing (NLP) | Basics
Natural Language Processing (NLP) | Basics
 
It's Machine Learning Basics -- For You!
It's Machine Learning Basics -- For You!It's Machine Learning Basics -- For You!
It's Machine Learning Basics -- For You!
 
Polymorphism in Python
Polymorphism in PythonPolymorphism in Python
Polymorphism in Python
 
DSA Question Bank
DSA Question BankDSA Question Bank
DSA Question Bank
 
Web API - Overview
Web API - OverviewWeb API - Overview
Web API - Overview
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
 
HTML Overview
HTML OverviewHTML Overview
HTML Overview
 
EM Algorithm
EM AlgorithmEM Algorithm
EM Algorithm
 
User story mapping
User story mappingUser story mapping
User story mapping
 
User stories
User storiesUser stories
User stories
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1 Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
 
Quality Circle | Case Study on Self Esteem | Team Opus Geeks.pdf
Quality Circle | Case Study on Self Esteem | Team Opus Geeks.pdfQuality Circle | Case Study on Self Esteem | Team Opus Geeks.pdf
Quality Circle | Case Study on Self Esteem | Team Opus Geeks.pdf
 
Multimedia Content and Content Acquisition
Multimedia Content and Content AcquisitionMultimedia Content and Content Acquisition
Multimedia Content and Content Acquisition
 
PHP Arrays_Introduction
PHP Arrays_IntroductionPHP Arrays_Introduction
PHP Arrays_Introduction
 
Leadership
LeadershipLeadership
Leadership
 

Recently uploaded

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

System Calls - Introduction

  • 2. Know it! In computing, a system call is a programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call allows 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. All programs needing resources must use system calls.
  • 3. Example For example, if we need to write a program code to read data from one file, copy that data into another file. The first information that the program requires is the name of the two files, the input and output files. In an interactive system, this type of program execution requires some system calls by OS. First call is to write a prompting message on the screen Second, to read from the keyboard, the characters which define the two files.
  • 4.
  • 5.
  • 6. Kernel Mode Vs User Mode
  • 8. Some use cases Reading and writing from files demand system calls. If a file system wants to create or delete files, system calls are required. System calls are used for the creation and management of new processes. Network connections need system calls for sending and receiving packets. Access to hardware devices like scanner, and printer, need a system call.
  • 9. wait() In some systems, a process needs to wait for another process to complete its execution. This type of situation occurs when a parent process creates a child process, and the execution of the parent process remains suspended until its child process executes. The suspension of the parent process automatically occurs with a wait() system call. When the child process ends execution, the control moves back to the parent process.
  • 10.
  • 11. fork() Processes use this system call to create processes that are a copy of themselves. With the help of this system Call parent process creates a child process, and the execution of the parent process will be suspended till the child process executes.
  • 13. getid() Getpid() is the function used to get the process ID of the process that calls that function. The PID for the initial process is 1, and then each new process is assigned a new Id. It is a simple approach to getting the PID.
  • 14. Example #include<stdio.h> #include<unistd.h> int main(){ fork(); printf("PID = %dn", getpid()); return 0; } fork() system call is used to create a separate, duplicate process)
  • 17. Example #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include <sys/wait.h> int main(){ int fd[2],n; char buffer[100]; pid_t p; pipe(fd); p = fork(); } if(p>0){ close(fd[0]); printf("Passing value to child!n"); write(fd[1],"Hello my child!!",15); printf("n"); wait(NULL); } else{ close(fd[1]); n = read(fd[0], buffer, 100); write(1,buffer,n); }
  • 19. In steps 1-3, the calling program pushes the parameters onto the stack. The first and third parameters are called by value, but the second one is called by its address as denoted by the & symbol. In step 4, the actual call to the library procedure is made. This instruction is the normal procedure call instruction used to call all procedures. In step 5, the library procedure places the system call number in a place where the operating system expects it, such as a register. In step 6, the library procedure executes a TRAP instruction to switch from user mode to kernel mode and start execution at a fixed address within the kernel. In step 7, the kernel examines the system call number and then dispatches it to the correct system call handler. This correct number is given in the table of system call handlers by pointers referenced at the system call number. In step 8, the system call handler runs. In step 9, the operation is completed, and the user is given back control once the TRAP instruction is set. In step 10, this procedure returns to the user program, like how all normal library procedures do. In step 11, the operating system has to clear the stack, so it increments it enough so that it is empty.
  • 20. Practice #include<stdio.h> #include<unistd.h> int main(){ fork(); fork(); fork(); fork(); printf("PID = %dn", getpid()); return 0; } How many times would the printf statement be executed??
  • 21. Practice #include<stdio.h> #include<unistd.h> int main(){ fork(); fork(); fork(); fork(); printf("PID = %dn", getpid()); return 0; } 16 process | 15 child process | 1 root process