What is a device controller?
A piece of hardware that manages a specific I/O device (like keyboard, disk, or printer). It has registers that the CPU uses to send commands and check status.
What does the PC (Program Counter) register do?
It stores the address of the next instruction to be executed.
What does the IR (Instruction Register) do?
It stores the current instruction that is being executed.
What is polling in I/O?
The CPU repeatedly checks a device to see if it is ready. This wastes CPU time.
What is interrupt-driven I/O?
The device notifies the CPU when it is ready, so the CPU can do other work in the meantime.
Which is more efficient, polling or interrupts?
Interrupts are more efficient because the CPU does not waste time constantly checking the device.
What does the ‘ls’ command do in Unix?
Lists files and directories in the current directory.
What does the ‘cat’ command do?
Displays the contents of a file.
What does the ‘mkdir’ command do?
Creates a new directory.
What does the ‘rm’ command do?
Removes (deletes) a file. With -r, it removes a directory.
What does the ‘cd’ command do?
Changes the current working directory.
How do you create a C source code file using vi?
Type ‘vi filename.c’, press ‘i’ to insert, write the code, press ESC, then ‘:wq’ to save and quit.
How do you compile a C program from the command line?
Use ‘gcc filename.c -o programname’.
How do you run a compiled C program?
Type ‘./programname’ in the terminal.
What does argc mean in C programs?
It is the number of command-line arguments passed to the program.
What does argv mean in C programs?
It is an array of strings containing the arguments themselves.
What does init() do in Unix?
It is the first process started by the system. It sets up all other processes.
What does fork() do?
It creates a new process by duplicating the current one. The new one is called the child process.
What does getpid() do?
Returns the process ID (PID) of the current process.
What does getppid() do?
Returns the process ID (PID) of the parent process.