System Call Flashcards

1
Q

What is a System Call?

A

A system call is a programmatic way for a user application to request a service from the operating system (OS). It acts as an interface between user programs and the kernel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why are System Calls Needed?

A

System calls are needed to allow user programs to perform tasks that require privileged access to hardware or kernel resources, enforce security, and provide a consistent interface for applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do System Calls Work?

A

1) The user program invokes a system call using a library function. 2) A software interrupt (trap) switches the CPU from user mode to kernel mode. 3) The kernel executes the requested operation. 4) The kernel returns the result to the user program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the Types of System Calls?

A

1) Process Control, 2) File Management, 3) Device Management, 4) Information Maintenance, 5) Communication, 6) Protection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Process Control in System Calls?

A

Process control system calls manage processes, such as creating, terminating, or executing them. Examples: fork(), exec(), exit(), wait().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is File Management in System Calls?

A

File management system calls manipulate files, such as creating, reading, writing, or deleting them. Examples: open(), read(), write(), close(), unlink().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Device Management in System Calls?

A

Device management system calls manage hardware devices, such as printers or disks. Examples: ioctl(), read(), write().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Information Maintenance in System Calls?

A

Information maintenance system calls retrieve or set system information. Examples: getpid(), time(), sysinfo().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Communication in System Calls?

A

Communication system calls facilitate inter-process communication (IPC). Examples: pipe(), shmget(), msgget().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Protection in System Calls?

A

Protection system calls manage access control and permissions. Examples: chmod(), chown().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a System Call Number?

A

A system call number is a unique identifier assigned to each system call. The kernel uses this number to identify the requested service.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a System Call Table?

A

A system call table is a data structure in the kernel that maps system call numbers to their corresponding functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Software Interrupt?

A

A software interrupt (e.g., int 0x80 on x86) triggers a switch from user mode to kernel mode to execute a system call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is Context Switching in System Calls?

A

Context switching is the process of saving the current state of a process (registers, program counter) and switching to kernel mode to execute a system call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the Overhead of a System Call?

A

The overhead of a system call includes context switching, kernel mode execution, and potential delays due to hardware access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can System Call Overhead be Reduced?

A

System call overhead can be reduced by using buffered I/O, batching operations, or minimizing the number of system calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the Role of the Kernel in System Calls?

A

The kernel executes system calls, manages hardware resources, and ensures security and isolation between processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the Difference Between a System Call and a Library Function?

A

A system call interacts with the kernel, while a library function runs in user space. Library functions may internally use system calls.

19
Q

What is the Purpose of the fork() System Call?

A

The fork() system call creates a new process by duplicating the current process. The new process is called the child process.

20
Q

What is the Purpose of the exec() System Call?

A

The exec() system call replaces the current process with a new program. It loads the new program into memory and starts its execution.

21
Q

What is the Purpose of the wait() System Call?

A

The wait() system call allows a parent process to wait for a child process to terminate and retrieve its exit status.

22
Q

What is the Purpose of the pipe() System Call?

A

The pipe() system call creates a pipe, which is a unidirectional communication channel between two processes.

23
Q

What is the Purpose of the open() System Call?

A

The open() system call opens a file and returns a file descriptor, which is used for subsequent file operations.

24
Q

What is the Purpose of the read() System Call?

A

The read() system call reads data from a file or device into a buffer.

25
Q

What is the Purpose of the write() System Call?

A

The write() system call writes data from a buffer to a file or device.

26
Q

What is the Purpose of the close() System Call?

A

The close() system call closes a file descriptor, releasing associated resources.

27
Q

What is the Purpose of the ioctl() System Call?

A

The ioctl() system call sends control commands to a device, such as configuring its settings.

28
Q

What is the Purpose of the getpid() System Call?

A

The getpid() system call returns the process ID of the current process.

29
Q

What is the Purpose of the time() System Call?

A

The time() system call returns the current time in seconds since the Unix epoch (January 1, 1970).

30
Q

What is the Purpose of the chmod() System Call?

A

The chmod() system call changes the permissions of a file or directory.

31
Q

What is the Purpose of the chown() System Call?

A

The chown() system call changes the ownership of a file or directory.

32
Q

What is the Difference Between fork() and exec()?

A

fork() creates a new process by duplicating the current process, while exec() replaces the current process with a new program.

33
Q

What is the Difference Between User Mode and Kernel Mode?

A

User mode restricts direct hardware access for applications, while kernel mode allows privileged access to hardware and critical operations.

34
Q

What is the Role of the System Call Table?

A

The system call table maps system call numbers to their corresponding kernel functions, enabling the kernel to execute the requested service.

35
Q

What is the Role of the init Process in System Calls?

A

The init process (PID 1) is the first process started by the kernel and manages all other processes, including handling orphaned processes.

36
Q

What is a Zombie Process?

A

A zombie process is a terminated process that remains in the process table until its parent reads its exit status.

37
Q

What is an Orphan Process?

A

An orphan process is a child process whose parent has terminated, and it is adopted by the init process (PID 1).

38
Q

What is a Daemon Process?

A

A daemon process is a background process that provides services, such as a web server or print spooler. It has no controlling terminal.

39
Q

What is the Purpose of the kill() System Call?

A

The kill() system call sends a signal to a process, such as terminating it (SIGKILL) or interrupting it (SIGINT).

40
Q

What is the Purpose of the pipe() System Call?

A

The pipe() system call creates a unidirectional communication channel between two processes, allowing them to exchange data.

41
Q

What is the Purpose of the shmget() System Call?

A

The shmget() system call allocates a shared memory segment, which can be accessed by multiple processes.

42
Q

What is the Purpose of the msgget() System Call?

A

The msgget() system call creates a message queue, which allows processes to exchange messages.

43
Q

What is the Purpose of the sysinfo() System Call?

A

The sysinfo() system call retrieves system statistics, such as memory usage, CPU load, and uptime.