SlideShare a Scribd company logo
Submit Search
Upload
Login
Signup
System Calls
Report
Anil Kumar Pugalia
Follow
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Apr. 3, 2019
•
0 likes
•
4,148 views
1
of
17
System Calls
Apr. 3, 2019
•
0 likes
•
4,148 views
Report
Technology
Anil Kumar Pugalia
Follow
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Recommended
System Calls
Anil Kumar Pugalia
9.7K views
•
14 slides
Character Drivers
Anil Kumar Pugalia
56.5K views
•
22 slides
Real Time Systems
Anil Kumar Pugalia
17.5K views
•
41 slides
Introduction to Linux
Anil Kumar Pugalia
4K views
•
33 slides
Kernel Programming
Anil Kumar Pugalia
24.3K views
•
25 slides
Architecture Porting
Anil Kumar Pugalia
5K views
•
12 slides
More Related Content
What's hot
Embedded Software Design
Anil Kumar Pugalia
6.9K views
•
29 slides
Processes
Anil Kumar Pugalia
7K views
•
33 slides
Linux Memory Management
Anil Kumar Pugalia
27.5K views
•
15 slides
Kernel Debugging & Profiling
Anil Kumar Pugalia
5.9K views
•
14 slides
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
3.9K views
•
27 slides
File System Modules
Anil Kumar Pugalia
25K views
•
27 slides
What's hot
(20)
Embedded Software Design
Anil Kumar Pugalia
•
6.9K views
Processes
Anil Kumar Pugalia
•
7K views
Linux Memory Management
Anil Kumar Pugalia
•
27.5K views
Kernel Debugging & Profiling
Anil Kumar Pugalia
•
5.9K views
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
•
3.9K views
File System Modules
Anil Kumar Pugalia
•
25K views
System calls
AfshanKhan51
•
330 views
Part 04 Creating a System Call in Linux
Tushar B Kute
•
3.8K views
Block Drivers
Anil Kumar Pugalia
•
38.1K views
Linux User Space Debugging & Profiling
Anil Kumar Pugalia
•
6.5K views
Linux Network Management
Anil Kumar Pugalia
•
11.2K views
Introduction to Linux
Anil Kumar Pugalia
•
11.2K views
System call
shahadat hossain
•
484 views
Introduction to System Calls
Vandana Salve
•
13.1K views
Kernel Debugging & Profiling
Anil Kumar Pugalia
•
18.8K views
Introduction to Linux Drivers
Anil Kumar Pugalia
•
64.4K views
Embedded Storage Management
Anil Kumar Pugalia
•
4.1K views
Mobile Hacking using Linux Drivers
Anil Kumar Pugalia
•
6K views
Studying a decade of Linux system calls
corpaulbezemer
•
581 views
Introduction to Embedded Systems
Anil Kumar Pugalia
•
18.4K views
Similar to System Calls
Operating system structures
PrathamKotian3
8 views
•
44 slides
Operation system structure
brysan30
1.2K views
•
54 slides
Ch2
ChhayaShelake
23 views
•
54 slides
Ch2
nubinny
2.8K views
•
50 slides
CH02.pdf
ImranKhan880955
8 views
•
28 slides
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
priyasoundar
156 views
•
79 slides
Similar to System Calls
(20)
Operating system structures
PrathamKotian3
•
8 views
Operation system structure
brysan30
•
1.2K views
Ch2
ChhayaShelake
•
23 views
Ch2
nubinny
•
2.8K views
CH02.pdf
ImranKhan880955
•
8 views
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
priyasoundar
•
156 views
MODULE 2.ppt
MohitJain21BCE1523
•
3 views
Chapter 2 - Operating System Structures
Wayne Jones Jnr
•
51.1K views
OS - Ch2
sphs
•
1.1K views
Ch2
rupalidhir
•
678 views
Structure of operating system
Rafi Dar
•
5.2K views
os
JustinMathew73
•
2 views
Chapter 2 Operating System Structures.ppt
ErenJeager20
•
72 views
ch2.ppt
Murali Krishna Kanajam
•
4 views
ch2.ppt
GomathiShanmugam5
•
4 views
Operating-System Structures
K Gowsic Gowsic
•
5 views
ch2.ppt
PoojaTripathi92
•
5 views
ch2.ppt
Sami Mughal
•
1 view
ch2.ppt
NirnayaNbstriker
•
5 views
Operating System - Unit I - Operating System Structures
cscarcas
•
1.6K views
More from Anil Kumar Pugalia
File System Modules
Anil Kumar Pugalia
20.6K views
•
37 slides
Embedded C
Anil Kumar Pugalia
25.6K views
•
20 slides
Playing with R L C Circuits
Anil Kumar Pugalia
2.8K views
•
17 slides
Audio Drivers
Anil Kumar Pugalia
20.6K views
•
11 slides
Video Drivers
Anil Kumar Pugalia
23.2K views
•
38 slides
Shell Scripting
Anil Kumar Pugalia
6.2K views
•
27 slides
More from Anil Kumar Pugalia
(19)
File System Modules
Anil Kumar Pugalia
•
20.6K views
Embedded C
Anil Kumar Pugalia
•
25.6K views
Playing with R L C Circuits
Anil Kumar Pugalia
•
2.8K views
Audio Drivers
Anil Kumar Pugalia
•
20.6K views
Video Drivers
Anil Kumar Pugalia
•
23.2K views
Shell Scripting
Anil Kumar Pugalia
•
6.2K views
References
Anil Kumar Pugalia
•
21.7K views
Functional Programming with LISP
Anil Kumar Pugalia
•
6.1K views
Power of vi
Anil Kumar Pugalia
•
3K views
gcc and friends
Anil Kumar Pugalia
•
14.2K views
"make" system
Anil Kumar Pugalia
•
4.2K views
Hardware Design for Software Hackers
Anil Kumar Pugalia
•
1.7K views
RPM Building
Anil Kumar Pugalia
•
4K views
Timers
Anil Kumar Pugalia
•
6.5K views
Threads
Anil Kumar Pugalia
•
10.1K views
Synchronization
Anil Kumar Pugalia
•
9K views
Processes
Anil Kumar Pugalia
•
7.5K views
Signals
Anil Kumar Pugalia
•
9.8K views
Linux File System
Anil Kumar Pugalia
•
24.4K views
Recently uploaded
Industry 4.0.pdf
Tery Lockitski
30 views
•
8 slides
Data Formats: Reading and writing JSON – XML - YAML
CSUC - Consorci de Serveis Universitaris de Catalunya
22 views
•
8 slides
AMAZON-RESUME.pdf
RegineRaneses
35 views
•
1 slide
Jino Clone: Develop a Car Wash Mobile App with Limited Resources
eSiteWorld TechnoLabs Pvt. Ltd.
21 views
•
13 slides
Swiss Re Reinsurance Solutions - Automated Claims Experience – Insurer Innova...
The Digital Insurer
22 views
•
13 slides
Webinar: Discover the Power of SpiraTeam - A Jira Alternative To Revolutioniz...
Inflectra
26 views
•
35 slides
Recently uploaded
(20)
Industry 4.0.pdf
Tery Lockitski
•
30 views
Data Formats: Reading and writing JSON – XML - YAML
CSUC - Consorci de Serveis Universitaris de Catalunya
•
22 views
AMAZON-RESUME.pdf
RegineRaneses
•
35 views
Jino Clone: Develop a Car Wash Mobile App with Limited Resources
eSiteWorld TechnoLabs Pvt. Ltd.
•
21 views
Swiss Re Reinsurance Solutions - Automated Claims Experience – Insurer Innova...
The Digital Insurer
•
22 views
Webinar: Discover the Power of SpiraTeam - A Jira Alternative To Revolutioniz...
Inflectra
•
26 views
Scaling out with WordPress
Konstantin Kovshenin
•
44 views
Smart Contracts - The Blockchain Beyond Bitcoin
Jim McKeeth
•
30 views
Unleashing the Power of Modern Carpooling Apps, Inspired by BlaBlaCar
Archie Cadell
•
26 views
Improving Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft ...
ThousandEyes
•
46 views
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
NicolasVuillamy1
•
35 views
Experts Live Europe 2023 - Ensure your compliance in Microsoft Teams with Mic...
Jasper Oosterveld
•
20 views
TaketoFujikawa_KES2023
Matsushita Laboratory
•
112 views
Knowledge graph use cases in natural language generation
Elena Simperl
•
78 views
Demystifying ML/AI
Matthew Reynolds
•
22 views
Regulating Generative AI - LLMOps pipelines with Transparency
Debmalya Biswas
•
40 views
Document Understanding as Cloud APIs and Generative AI Pre-labeling Extractio...
DianaGray10
•
33 views
2023 Ivanti September Patch Tuesday
Ivanti
•
87 views
The Rise of the Machines: How AI will shape our lives in 2024
Iain Martin
•
39 views
class and object in c++.pptx
Adarsh College, Hingoli
•
177 views
System Calls
1.
© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. System Calls
2.
2© 2010-19 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-19 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-19 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-19 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-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. System Call Execution Flow … xyz() ... xyz() { … SYSCALL … } system_call: … sys_xyz() SYSEXIT sys_xyz() { … ... } System Call invocation in application program Wrapper routine in libc standard library System Call handler System Call service routine User Mode Kernel Mode
7.
7© 2010-19 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, ...)
8.
8© 2010-19 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)
9.
9© 2010-19 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
10.
10© 2010-19 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
11.
11© 2010-19 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
12.
12© 2010-19 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
13.
13© 2010-19 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
14.
14© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. System Call: access Helps to determine whether the calling process has access permission for a particular file int access(const char *pathname, int mode); pathname – Path to the file mode – Accessibility checks. F_OK or a mask consisting of bitwise or of R_OK, W_OK and X_OK
15.
15© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. System Call: fcntl Is used for performing the various advanced operations on an open file descriptor It allows to place a read or write lock on the file More than one process can hold the read lock, while only one process can hold the write lock int fcntl(int fd, int cmd, ... /* arg */ ) fd – File descriptor cmd – Operation to perform … – Arguments
16.
16© 2010-19 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
17.
17© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?