L-1.7: System Calls in Operating system and its types in Hindi
Summary
TLDRThis video script explains the concept of system calls, which are essential for transitioning from user mode to kernel mode in operating systems. It covers the necessity of system calls for accessing hardware devices and files, and categorizes them into file-related, device-related, information-related, process control, and inter-process communication system calls. The script also touches on system calls for security and protection, emphasizing their importance in operating systems.
Takeaways
- π **User Mode vs Kernel Mode**: Applications run in user mode, but to access OS functionalities, they must switch to kernel mode.
- π² **Purpose of System Calls**: System calls are the programmatic method to transition from user mode to kernel mode.
- π» **System Calls in Programming**: In languages like C, system calls (e.g., read, write, open) are used to interact with the kernel for tasks like file handling or device access.
- π **Variety in System Calls**: Different operating systems have different sets of system calls; for instance, Windows has around 700 system calls.
- π **File-Related System Calls**: These are used for creating, opening, reading, and writing files, requiring kernel privileges.
- π₯οΈ **Device-Related System Calls**: Necessary for accessing hardware devices like hard disks, printers, or monitors.
- π **Information-Related System Calls**: Used to retrieve metadata about processes, devices, and system information like time and date.
- π **Process Control System Calls**: Facilitate process loading, execution, and control, including the creation of child processes with fork.
- π **Inter-Process Communication (IPC)**: System calls like Pipe() and Shmget() enable communication between processes.
- π‘οΈ **Security and Protection**: System calls such as chmod and umask are used to manage file and system security.
Q & A
What is the primary purpose of a system call?
-The primary purpose of a system call is to allow a program running in user mode to request services from the operating system's kernel, thus transitioning from user mode to kernel mode.
Why can't user mode applications directly access hardware or system resources?
-User mode applications cannot directly access hardware or system resources because they do not have the necessary privileges to do so. Direct access must be mediated by the operating system's kernel through system calls to ensure security and proper resource management.
What is the difference between user mode and kernel mode?
-User mode is a restricted environment where applications run, while kernel mode is a privileged mode that gives the operating system direct access to hardware and system resources. System calls are used to transition from user mode to kernel mode to perform operations that require higher privileges.
Can you provide an example of a system call in a C program?
-Yes, in a C program, system calls such as 'read', 'write', 'open', 'close', and 'fork' are used to perform operations like reading from or writing to a file, opening or closing a file descriptor, or creating a child process.
How does the concept of system calls vary across different operating systems?
-The concept of system calls remains the same across different operating systems, but the specific system calls available and their implementation can vary. For example, Linux has a different set of system calls compared to Windows, which has around 700 system calls.
What is the role of APIs in the context of system calls?
-APIs (Application Programming Interfaces) provide a higher-level abstraction for developers, allowing them to perform operations without directly using system calls. APIs often internally call system calls to execute the required tasks.
What are file-related system calls and why are they necessary?
-File-related system calls are used to perform operations on files, such as creating, opening, reading, and writing files. They are necessary because they allow user mode applications to interact with files on the disk through the kernel, which manages file access and permissions.
How do device-related system calls enable access to hardware?
-Device-related system calls enable access to hardware by allowing user mode applications to request the kernel to perform operations on devices like hard disks, printers, or monitors. This is done to ensure that hardware access is controlled and secure.
What is the significance of the 'fork' system call in creating a multiprocessing environment?
-The 'fork' system call is significant because it allows a process to create a child process, effectively duplicating itself. This is the foundation for multiprocessing, where multiple processes can run concurrently and perform different tasks.
What are inter-process communication (IPC) system calls and why are they used?
-Inter-process communication system calls are used to allow two or more processes to communicate with each other. They are used for data exchange and synchronization between processes, and can involve mechanisms like pipes, shared memory, or message queues.
Can you explain the role of 'getpid' and 'getppid' system calls?
-Yes, 'getpid' is used to obtain the process ID of the current process, while 'getppid' retrieves the process ID of the parent process. These system calls provide information related to process identification, which can be useful for process management and tracking.
Outlines
π» Understanding System Calls
The paragraph introduces the concept of system calls, explaining the necessity of transitioning from user mode to kernel mode to access operating system functionalities. It uses the example of a C program to illustrate how arithmetic operations are performed in user mode, but displaying the result on a monitor or accessing hardware requires kernel mode. The paragraph further explains that system calls are the programmatic way to make this transition and access kernel functionalities. It mentions direct use of system calls in Linux for operations like read, write, close, open, and fork, contrasting it with the use of APIs or library functions like printf in other systems, which indirectly invoke system calls. The paragraph also categorizes system calls into file-related, device-related, and information-related, providing examples of each.
π System Call Categories and Their Uses
This paragraph delves deeper into the different types of system calls and their specific uses. It discusses file-related system calls, which are essential for creating, opening, reading, and writing files, emphasizing that these operations require kernel privileges granted through system calls. The paragraph then moves on to device-related system calls, explaining that accessing hardware like hard disks, printers, or monitors necessitates system calls to obtain operating system privileges. It introduces the concept of metadata and information-related system calls, which are used to retrieve details about processes and system attributes. The discussion continues with process control system calls, which are crucial for loading and executing programs, creating child processes with fork, and managing process synchronization with wait and signal system calls. The paragraph concludes with communication system calls, focusing on inter-process communication mechanisms like Pipes and shared memory, and system calls related to security and protection, such as chmod and umask.
Mindmap
Keywords
π‘System Call
π‘User Mode
π‘Kernel Mode
π‘API
π‘File System Calls
π‘Device System Calls
π‘Information Related System Calls
π‘Process Control System Calls
π‘Inter-Process Communication (IPC)
π‘Protection and Security System Calls
π‘System Calls Categorization
Highlights
System calls are a programmatic way to transition from user mode to kernel mode.
User mode is used for general application and API usage, while kernel mode is for accessing operating system functionalities.
System calls enable access to kernel functionalities such as device access and file manipulation.
In a C program, arithmetic operations are performed in user mode, but outputting to a monitor requires a system call.
System calls are necessary for accessing hardware like printers and monitors through the operating system.
File operations such as creating, opening, reading, and writing files are done through file-related system calls.
Device-related system calls are used for accessing hardware devices which are governed by the operating system.
Information-related system calls provide metadata about processes, devices, and system attributes like size, name, and permissions.
Process control system calls are used for loading programs into main memory and executing them.
The fork system call is crucial for creating child processes in a multiprocessing environment.
Process synchronization can be achieved through system calls like wait and signal.
Inter-process communication involves system calls such as Pipe() and Shmget() for Pipes and shared memory.
System calls also include those related to protection and security, like chmod for changing file permissions.
Linux provides direct access to system calls such as read, write, close, open, and fork.
Windows has around 700 system calls, indicating a large number of functionalities accessible through system calls.
Many operating systems offer APIs or libraries that indirectly access system calls, such as printf for printing.
System calls are categorized into file-related, device-related, information-related, process control, communication, and security.
Understanding the concept and importance of system calls is crucial for operating system functionality.
Transcripts
Hello friends, Welcome to Gate Smashers
The topic is system call... In the last video we discussed how we work in user mode & kernel mode
If the user is using any application or API or writing any program
then we generally writes it in user mode
But if I wants to access any functionality of operating system then I have to go in kernel mode
So because our access is on the user mode because we are accessing the user
so to go in kernel mode we use system call
System call is a programmatic way through which we shifts from user mode to kernel mode
or can access the functionalities of kernel and operating system
Like if I'd take a simple example if we are writing a C program
and I want to get any value printed on monitor let's say 2 + 2 = 4
then 2 + 2 is up to user mode, processor will do 2 + 2 no problem
But we have to get it printed on the monitor or if I want to get something printed
or I want to access printer, so wherever I have to access devices, I've to take help and do it through kernel
Kernel means through operating system `Same way if I want to access some file
Let's say I want o perform a transaction want to change data in some file
File is in hard disk.. so again, to access any file or hard disk, I've to go in kernal mode
Because these all devices and resources are being governed by operating system
so in operating system kernal is the main logical unit
So here I've to take help of system call and system call is generally...
Many times many operating systems are like if we talk about Linux,
then when we write C program in the text editor then we can use system call there directly
Like we can use read, write, close, open, fork etc and many other system calls directly
And generally in Linux operating system or if we'll talk about any other system also
There're hundreds of system call...
same way if we'd talk about window's then there're around 700 system calls
But there are many operating systems where we don't write system calls directly
We rather use APIs or we uses the local libraries like printf
Or scanner... printf means that we want to get some value printed,
then we're writing Printf. But that printf or scanner is not system call
Printf is a function, but that function is accessing the system call,
so print means writing on the monitor so whether you use system call directly
or you use some API or any function but at the end work will be done through system call
because system call will invoke kernal to perform this work
so as I said system call generally varies according to operating system
Many of them have around 300 system calls Window 7 have around 700 system calls
so we categories these system calls First we have file related system call
First we have file related system call means where we want to access any file
Let me tell you with a simple example
What happens generally is... when we write any C program
then we are writing that program using some API or application
But when we execute that program
then we says in operating system that the program has become process now
means when it's in running mode then it became process
And running mode means that process will in the RAM
Means that process has arrived in the RAM now and our operating system also i.e. kernal is in RAM also
I'm just taking a general architecture...
many times just a part of code lies in the RAM rather than whole code or kernal
so we are talking through a simple example where it says that our kernal is in main memory and process also
Now if we want to do any execution in the process
Let's say I want to access some file, then this process don't have privilege
that privilege will be given by kernal So process will invoke system call and will access that file
So all this work here has been done through system call So if we'd talk about file, then what we do in file?
Let's say I've to create some file... Create a file
let's say I want to open a file, want to read a file or write some file
so all the file related work that we are doing here
we are doing all that through file related system calls
Next is device related system call, so device related system call means
if I want to access any device or hardware here we are calling device as hardware
If we want to access hardware whether it is hard disk, printer or monitor...
so to access all these devices... User can never do direct access, he has to take privilege
Privilege will be given by operating system so here we'll again take privilege through system call
Whether we are reading any device or writing on a device or repositioning value of that device
or we are accessing its attributes
Same way we use IOctrl... we use this to control input output devices
or to control a file also... although, file control is a header file but we generally use it here
Next we have... Information related
Information means regarding processes or devices, if I want to take information of any attribute
there we use information related system call like getpid is a simple example
We use getpid if I want to know about some process's ID, getppid means if I want to know about parent ID
Wherever we need any process related information which we call metadata in general term
Means metadata related to a data is...
data is like there's a audio file... and the content in audio file is its data
But data related to it.. like its size, file name, file's permission, file's extension... All this is called attribute
So if I want to access a data like this for this we use information related system call
Same way if I want access system's time, system's date, system's data...
then in that case we use information related
Then process control... this is also a major system call that we use
where if you are getting a process loaded
As I just told you, generally the programs that we write or save,
we are doing that in secondary memory in hard disk because we want to save it permanently
But when we have to load them in main memory or want execute them
for that we use process control system call
if you want to abort a process...
Fork system call... this is a very important system call
fork system call means like we talk about multi processing environment in operating system
Means we want to do multiple processes and tasks at a time
for that we use multi threading environment means we run multiple threads related to the process
or we can use fork system call... In fork system call, a process creates its own child process
And that child process is doing its work parent process is also doing its work
this way we can create a multiprocessing environment here
so we create fork system call also through process control system call
wait & signal... we use it under process synchronization
if you want some process to wait or want to increase semaphore values,
or want to allocate memory, so we can access all these things through this system call
Then communication... In communication we generally use inter process communication
Inter process communication means... two processes are communicating with each other
they can either use this Pipe() method or shared memory
so here we have pipe(0 system call, Shmget() that we use to get value of shared memory
or if I want to create or terminate connections, we have system calls related to it here
So these are major categorizations of system call we have system calls other than these also
Like system calls related to protection and security where we use chmod, privileges...
if I want to change on any file
then we can use chmod, umask and many other privileges and system calls that we use
so you con't have to directly memorize these system calls
but at least you should be clear with their idea that why we use system call
and what is there importance in operating system
So this is all about the system calls
Thank You!
Browse More Related Video
5.0 / 5 (0 votes)