L-1.7: System Calls in Operating system and its types in Hindi
Introduction to System Calls
In this section, the speaker introduces the concept of system calls and explains their role in accessing operating system functionalities.
What are System Calls?
- System calls are a programmatic way to shift from user mode to kernel mode or access the functionalities of the operating system.
- They allow users to access resources and devices governed by the operating system, such as printers, files, and hard disks.
- System calls can be used directly through programming languages like C or through APIs and local libraries.
Different Operating Systems and System Calls
- Linux allows direct usage of system calls in C programs, with hundreds of available system calls.
- Windows has around 700 system calls. However, some operating systems use APIs or local libraries instead of directly writing system calls.
Categories of System Calls
- File-related system calls are used to access files and perform operations on them.
- Other categories of system calls include process control, device control, communication control, memory management, etc.
[0:03:something] (timestamp not provided) Accessing Files Using System Calls
This section focuses on how file-related system calls work and their importance in accessing files within an operating system.
Execution Process and File Access
- When a C program is executed, it becomes a process running in the RAM.
- To access files, the process needs to invoke system calls to gain privileges from the kernel.
Importance of System Calls for File Access
- System calls enable processes to access files and perform operations on them.
- The operating system's kernel provides the necessary privileges for file access through system calls.
Timestamps were not provided for this section, so approximate timestamps have been used based on the transcript content.
File and Device Related System Calls
In this section, the speaker discusses file and device related system calls, which are used to perform operations on files and access hardware devices.
Opening, Reading, and Writing Files
- File-related work is performed through file-related system calls. These system calls allow us to open, read, and write files.
- Users cannot directly access devices or hardware. They need to take privilege from the operating system through device-related system calls.
Accessing Devices
- To access hardware devices such as hard disks, printers, or monitors, we use device-related system calls.
- User privileges for accessing devices are granted by the operating system through these system calls.
Controlling Input/Output Devices
- The IOctrl function is used to control input/output devices. It can also be used to control files.
Information Related System Calls
This section focuses on information related system calls that provide information about processes, devices, and other attributes.
Retrieving Process Information
- Information related system calls are used to retrieve information about processes or devices.
- Examples of information related system calls include getpid (to get process ID) and getppid (to get parent process ID).
Metadata and Attributes
- Metadata refers to data related to a file or resource. It includes attributes such as size, filename, permissions, and extensions.
- Information related system calls are used to access data attributes.
System Time and Date
- Information related system calls can also be used to retrieve the current time, date, or other data from the operating system.
Process Control System Calls
This section covers process control system calls that manage processes in an operating system.
Loading Processes into Memory
- Process control system calls are used when loading processes into main memory for execution.
- These system calls are essential for executing programs stored in secondary memory (e.g., hard disk) and creating a multiprocessing environment.
Fork System Call
- The fork system call is crucial for creating multiple processes or tasks in a multitasking environment.
- It allows a process to create its own child process, enabling parallel execution of tasks.
Process Synchronization
- Wait and signal system calls are used for process synchronization.
- They can be used to make a process wait or increase semaphore values, allocate memory, and perform other synchronization tasks.
Interprocess Communication
This section discusses interprocess communication methods used to facilitate communication between two processes.
Pipe and Shared Memory
- Interprocess communication can be achieved through methods like pipe() and shared memory.
- Pipe() system call creates a pipe for communication between two processes, while Shmget() retrieves the value of shared memory.
Creating and Terminating Connections
- System calls related to creating or terminating connections are available for interprocess communication purposes.
Other System Calls
There are additional system calls related to protection, security, privileges, etc. These include chmod, umask, and other privilege-related system calls.
System Calls
This section discusses system calls.
Introduction to System Calls
- System calls are a fundamental part of operating systems.
- They provide an interface for applications to interact with the operating system kernel.
- System calls allow applications to perform various tasks such as file operations, process management, and network communication.
Types of System Calls
- There are different types of system calls, including:
- File-related system calls: Used for file operations such as opening, reading, writing, and closing files.
- Process-related system calls: Used for process management tasks like creating new processes or terminating existing ones.
- Network-related system calls: Used for network communication tasks such as establishing connections and sending/receiving data over the network.
Examples of System Calls
- Some examples of commonly used system calls include:
open(): Opens a file and returns a file descriptor.
read(): Reads data from a file into a buffer.
write(): Writes data from a buffer to a file.
fork(): Creates a new process by duplicating the existing process.
exec(): Replaces the current process with a new executable program.
Benefits of Using System Calls
- Using system calls provides several benefits:
- Portability: Applications can be written in a platform-independent manner by relying on standard system call interfaces.
- Security: System calls help enforce security policies by controlling access to resources and preventing unauthorized actions.
- Abstraction: System calls abstract low-level hardware details, allowing applications to focus on higher-level functionality without worrying about hardware-specific implementation details.
Conclusion
- Understanding system calls is essential for developing applications that interact with the operating system kernel efficiently and securely.