SlideShare a Scribd company logo
1 of 14
© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
System Calls
2© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
W's of System Calls
System Call vs Library Function
System Call Tracing
Hands-On
3© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
W's of System Calls
User programs vs Kernel programs
Runs in different spaces
Runs with different privileges
User space not allowed access to Kernel space
But they need the Kernel services
OS provides service points
For User programs
To request services from the Kernel
In Linux, these are called System Calls
4© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
System Calls in Linux
About 300 in count
Listing: /usr/include/asm/unistd.h
Provide layer between
Kernel Space (typically hardware)
User Space (typically user process)
Serve three purposes
Provide an Abstracted h/w interface for user space
Ensures System security and stability
Makes Process Management easier
5© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Working of a Linux System Call
Implemented as an ordinary function in the Linux Kernel
Executes like others in the Kernel Space
However, the call to that function isn't ordinary
When a user program makes a system call
Arguments are packaged up and handed to the kernel
A special procedure is required to transfer control to the kernel
Kernel takes over execution of the program until the call completes
Kernel transfers control back to the program with return value
Special procedure is typically achieved using “trap”
6© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Linux System Call Wrappers
Every System Call has standard steps
GNU C library (glibc) abstracts them
By wrapping with functions of same name
For easy invocation
Examples
I/O functions: open, read, ...
We rarely invoke direct system calls
But rather these system call (wrapper) functions
Any Exception?
Custom defined system call – using syscall(sno, ...)
7© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Contrast with a Library Function
A library function is an ordinary function
It resides in a library external to the program
But in the User Space only
Moreover, the call to it is also ordinary
Arguments placed in processor registers or the stack
Execution transferred to the start of the function
Typically resides in a loaded shared library
In the User Space only
Examples
fopen, printf, getopt, mkstemp (all from glibc)
8© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Return Values
Library functions often return pointers
Example: FILE * fp = fopen("harry","r");
NULL indicates failure
System calls usually return an integer
Example: int res = open(“harry”, O_RDONLY);
Return value
>= 0 indicates success
< 0, typically -1 indicates failure, and error is set in errno
Note the counter intuitive return of System Calls
Opposite way round
Cannot use as Boolean
9© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
More Information
Manual Sections
2 System calls e.g. _exit, read, write
3 Library calls e.g. exit, printf
7 Miscellaneous e.g. ascii, fifo, pthreads
9 POSIX Programmer Manual
Info pages are also available
10© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Tracing System Calls
Command: strace <program> [args]
Traces the execution of <program>
And Lists
System Calls made by <program>
Signals received by <program>
Controlled by various options
An interesting one is “-e”
Example
strace cat /dev/null
11© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Pros & Cons
Pros
System calls provide direct & hence more control over the
kernel services
Library functions abstract the nitty-gritty of architecture or
OS specific details of the system calls
Library functions can provide wrappers over repeated set
of system calls
Cons
Library functions may have overheads
System calls at times may expose the underlying system
dependency
12© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Let's try some Examples
System Call Invocation
System calls vs Library functions
File Operations
Observe the various system calls invoked
Use strace
13© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
W's of System Calls
Working of a System Call & syscall()
System Call Wrapper Functions
System Call vs Library Function
Pros & Cons
System Call Tracing
Hands-On
14© 2010-17 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?

More Related Content

What's hot (20)

Operating System Lecture 1
Operating System Lecture 1Operating System Lecture 1
Operating System Lecture 1
 
Memory management in linux
Memory management in linuxMemory management in linux
Memory management in linux
 
operating system structure
operating system structureoperating system structure
operating system structure
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Windows process-scheduling
Windows process-schedulingWindows process-scheduling
Windows process-scheduling
 
Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 
Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 
Justificación
JustificaciónJustificación
Justificación
 
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIKernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
 
Process creation and termination In Operating System
Process creation and termination In Operating SystemProcess creation and termination In Operating System
Process creation and termination In Operating System
 
Processes in unix
Processes in unixProcesses in unix
Processes in unix
 
OS - Ch2
OS - Ch2OS - Ch2
OS - Ch2
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
kali linux
kali linuxkali linux
kali linux
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 

Viewers also liked (20)

Embedded C
Embedded CEmbedded C
Embedded C
 
Timers
TimersTimers
Timers
 
Signals
SignalsSignals
Signals
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Threads
ThreadsThreads
Threads
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
 
Network Drivers
Network DriversNetwork Drivers
Network Drivers
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
References
ReferencesReferences
References
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
 
Interrupts
InterruptsInterrupts
Interrupts
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
Bootloaders
BootloadersBootloaders
Bootloaders
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISP
 
Board Bringup
Board BringupBoard Bringup
Board Bringup
 
Embedded Software Design
Embedded Software DesignEmbedded Software Design
Embedded Software Design
 
Mobile Hacking using Linux Drivers
Mobile Hacking using Linux DriversMobile Hacking using Linux Drivers
Mobile Hacking using Linux Drivers
 
Linux File System
Linux File SystemLinux File System
Linux File System
 

Similar to System Calls (20)

System Calls
System CallsSystem Calls
System Calls
 
W5 system call, DD, OS structure.ppt
W5 system call, DD, OS structure.pptW5 system call, DD, OS structure.ppt
W5 system call, DD, OS structure.ppt
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Operating System- Structures of Operating System
Operating System- Structures of Operating SystemOperating System- Structures of Operating System
Operating System- Structures of Operating System
 
Operating system structures
Operating system structuresOperating system structures
Operating system structures
 
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESOPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
 
Operation system structure
Operation system structureOperation system structure
Operation system structure
 
Ch2
Ch2Ch2
Ch2
 
CH02.pdf
CH02.pdfCH02.pdf
CH02.pdf
 
MODULE 2.ppt
MODULE 2.pptMODULE 2.ppt
MODULE 2.ppt
 
Ch2
Ch2Ch2
Ch2
 
OS-ch02-part-1-2024.ppt
OS-ch02-part-1-2024.pptOS-ch02-part-1-2024.ppt
OS-ch02-part-1-2024.ppt
 
ch2.ppt
ch2.pptch2.ppt
ch2.ppt
 
Linux Kernel Overview
Linux Kernel OverviewLinux Kernel Overview
Linux Kernel Overview
 
Chapter 2 Operating System Structures.ppt
Chapter 2 Operating System Structures.pptChapter 2 Operating System Structures.ppt
Chapter 2 Operating System Structures.ppt
 
ch2.ppt
ch2.pptch2.ppt
ch2.ppt
 
ch2.ppt
ch2.pptch2.ppt
ch2.ppt
 
ch2.ppt
ch2.pptch2.ppt
ch2.ppt
 
Operating-System Structures
Operating-System StructuresOperating-System Structures
Operating-System Structures
 

More from Anil Kumar Pugalia (13)

File System Modules
File System ModulesFile System Modules
File System Modules
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Processes
ProcessesProcesses
Processes
 
Playing with R L C Circuits
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C Circuits
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
Power of vi
Power of viPower of vi
Power of vi
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
"make" system
"make" system"make" system
"make" system
 
Hardware Design for Software Hackers
Hardware Design for Software HackersHardware Design for Software Hackers
Hardware Design for Software Hackers
 
RPM Building
RPM BuildingRPM Building
RPM Building
 
Processes
ProcessesProcesses
Processes
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

System Calls

  • 1. © 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. System Calls
  • 2. 2© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? W's of System Calls System Call vs Library Function System Call Tracing Hands-On
  • 3. 3© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. W's of System Calls User programs vs Kernel programs Runs in different spaces Runs with different privileges User space not allowed access to Kernel space But they need the Kernel services OS provides service points For User programs To request services from the Kernel In Linux, these are called System Calls
  • 4. 4© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. System Calls in Linux About 300 in count Listing: /usr/include/asm/unistd.h Provide layer between Kernel Space (typically hardware) User Space (typically user process) Serve three purposes Provide an Abstracted h/w interface for user space Ensures System security and stability Makes Process Management easier
  • 5. 5© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Working of a Linux System Call Implemented as an ordinary function in the Linux Kernel Executes like others in the Kernel Space However, the call to that function isn't ordinary When a user program makes a system call Arguments are packaged up and handed to the kernel A special procedure is required to transfer control to the kernel Kernel takes over execution of the program until the call completes Kernel transfers control back to the program with return value Special procedure is typically achieved using “trap”
  • 6. 6© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Linux System Call Wrappers Every System Call has standard steps GNU C library (glibc) abstracts them By wrapping with functions of same name For easy invocation Examples I/O functions: open, read, ... We rarely invoke direct system calls But rather these system call (wrapper) functions Any Exception? Custom defined system call – using syscall(sno, ...)
  • 7. 7© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Contrast with a Library Function A library function is an ordinary function It resides in a library external to the program But in the User Space only Moreover, the call to it is also ordinary Arguments placed in processor registers or the stack Execution transferred to the start of the function Typically resides in a loaded shared library In the User Space only Examples fopen, printf, getopt, mkstemp (all from glibc)
  • 8. 8© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Return Values Library functions often return pointers Example: FILE * fp = fopen("harry","r"); NULL indicates failure System calls usually return an integer Example: int res = open(“harry”, O_RDONLY); Return value >= 0 indicates success < 0, typically -1 indicates failure, and error is set in errno Note the counter intuitive return of System Calls Opposite way round Cannot use as Boolean
  • 9. 9© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. More Information Manual Sections 2 System calls e.g. _exit, read, write 3 Library calls e.g. exit, printf 7 Miscellaneous e.g. ascii, fifo, pthreads 9 POSIX Programmer Manual Info pages are also available
  • 10. 10© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Tracing System Calls Command: strace <program> [args] Traces the execution of <program> And Lists System Calls made by <program> Signals received by <program> Controlled by various options An interesting one is “-e” Example strace cat /dev/null
  • 11. 11© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Pros & Cons Pros System calls provide direct & hence more control over the kernel services Library functions abstract the nitty-gritty of architecture or OS specific details of the system calls Library functions can provide wrappers over repeated set of system calls Cons Library functions may have overheads System calls at times may expose the underlying system dependency
  • 12. 12© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Let's try some Examples System Call Invocation System calls vs Library functions File Operations Observe the various system calls invoked Use strace
  • 13. 13© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? W's of System Calls Working of a System Call & syscall() System Call Wrapper Functions System Call vs Library Function Pros & Cons System Call Tracing Hands-On
  • 14. 14© 2010-17 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?