Podcast
Questions and Answers
Which of the following is a primary benefit of the abstraction provided by an operating system?
Which of the following is a primary benefit of the abstraction provided by an operating system?
- Improved portability of programs across different hardware. (correct)
- Direct hardware access for enhanced performance.
- Reduced security due to unrestricted resource access.
- Increased complexity for programmers needing to understand low-level details.
Why is preemptive multitasking important in a multi-user operating system?
Why is preemptive multitasking important in a multi-user operating system?
- It ensures fair CPU usage by preventing any single program from dominating the system. (correct)
- It simplifies the OS by eliminating the need for context switching.
- It reduces security risks by limiting the number of processes that can run simultaneously.
- It allows a single program to monopolize the CPU for maximum performance.
What is a key advantage of a monolithic kernel architecture?
What is a key advantage of a monolithic kernel architecture?
- Better fault tolerance, preventing a single failure from crashing the entire system.
- Enhanced security because failures are isolated to user space.
- Faster execution speed due to fewer context switches. (correct)
- Increased modularity, making it easier to update individual components.
Which of the following is a characteristic of a microkernel architecture?
Which of the following is a characteristic of a microkernel architecture?
What is the purpose of FUSE (Filesystem in Userspace)?
What is the purpose of FUSE (Filesystem in Userspace)?
Which user interface type is known for being powerful and scriptable but having a steeper learning curve?
Which user interface type is known for being powerful and scriptable but having a steeper learning curve?
Why does the operating system differentiate between kernel mode (Ring 0) and user mode?
Why does the operating system differentiate between kernel mode (Ring 0) and user mode?
What is the primary function of a PID (Process ID)?
What is the primary function of a PID (Process ID)?
Which of the following is the MOST significant difference between a program binary and a process?
Which of the following is the MOST significant difference between a program binary and a process?
A program is in the 'Waiting' state. What is the MOST likely reason for this?
A program is in the 'Waiting' state. What is the MOST likely reason for this?
Which segment of a process's virtual address space is responsible for storing dynamically allocated memory?
Which segment of a process's virtual address space is responsible for storing dynamically allocated memory?
What is the significance of User ID (UID) 0?
What is the significance of User ID (UID) 0?
What is the key distinction between library calls and system calls?
What is the key distinction between library calls and system calls?
Which of the following BEST describes how higher-level abstractions contribute to software portability?
Which of the following BEST describes how higher-level abstractions contribute to software portability?
What is the primary difference between an internal (built-in) command and an external command in a shell environment?
What is the primary difference between an internal (built-in) command and an external command in a shell environment?
What distinguishes direct execution from indirect execution of code?
What distinguishes direct execution from indirect execution of code?
What is the primary role of the init
process (PID 1) in a Linux-based system?
What is the primary role of the init
process (PID 1) in a Linux-based system?
Which of the following scenarios accurately describes a 'zombie process'?
Which of the following scenarios accurately describes a 'zombie process'?
How does the SA_RESTART
flag in signal handling address concurrency issues?
How does the SA_RESTART
flag in signal handling address concurrency issues?
Which of the following commands would send a termination signal to a process with PID 1234?
Which of the following commands would send a termination signal to a process with PID 1234?
In a shell pipeline, what is the fundamental function of the |
(pipe) operator?
In a shell pipeline, what is the fundamental function of the |
(pipe) operator?
What is the key difference between using >
and >>
for redirection in a shell command?
What is the key difference between using >
and >>
for redirection in a shell command?
If your current directory is /home/user/documents
, what does the relative pathname ./reports/final.txt
refer to?
If your current directory is /home/user/documents
, what does the relative pathname ./reports/final.txt
refer to?
What is the primary purpose of the ioctl()
function?
What is the primary purpose of the ioctl()
function?
A system administrator notices a server is running out of disk space but du
and df
report significantly different usage. What is the most likely explanation for this discrepancy?
A system administrator notices a server is running out of disk space but du
and df
report significantly different usage. What is the most likely explanation for this discrepancy?
Which of the following scenarios would benefit most from using a user-space file system like FUSE?
Which of the following scenarios would benefit most from using a user-space file system like FUSE?
A program compiled with dynamic linking is deployed on a system that is missing one of the shared libraries it depends on. What is the most likely outcome when the program is executed?
A program compiled with dynamic linking is deployed on a system that is missing one of the shared libraries it depends on. What is the most likely outcome when the program is executed?
A developer wants to ensure that their application has access to specific environment variables, regardless of the user's system configuration. Which approach is the most reliable?
A developer wants to ensure that their application has access to specific environment variables, regardless of the user's system configuration. Which approach is the most reliable?
An application needs to store frequently accessed temporary files. Considering performance and persistence, which file system would be most suitable?
An application needs to store frequently accessed temporary files. Considering performance and persistence, which file system would be most suitable?
Which of the following is the primary function of the /dev/stderr
device file in a Linux system?
Which of the following is the primary function of the /dev/stderr
device file in a Linux system?
After a user enters their username at the login prompt, what is the next critical step in the standard Linux login process?
After a user enters their username at the login prompt, what is the next critical step in the standard Linux login process?
In the /etc/passwd
file, what does the 'x' character typically signify in the password field of a user account entry?
In the /etc/passwd
file, what does the 'x' character typically signify in the password field of a user account entry?
Given the /etc/passwd
entry john:x:1002:1002:John Doe:/home/john:/bin/zsh
, which statement accurately describes John's account?
Given the /etc/passwd
entry john:x:1002:1002:John Doe:/home/john:/bin/zsh
, which statement accurately describes John's account?
What is the correct way to permanently set an environment variable named EDITOR
to vim
for all future sessions in a Linux environment?
What is the correct way to permanently set an environment variable named EDITOR
to vim
for all future sessions in a Linux environment?
If a user executes the command echo $PATH
in their terminal, what type of information is most likely to be displayed?
If a user executes the command echo $PATH
in their terminal, what type of information is most likely to be displayed?
Which command would correctly redirect both standard output and standard error of a script named my_script.sh
to a file named output.log
?
Which command would correctly redirect both standard output and standard error of a script named my_script.sh
to a file named output.log
?
A user wants to run a program and ensure that only error messages are displayed on the terminal, while all standard output is discarded. Which command achieves this?
A user wants to run a program and ensure that only error messages are displayed on the terminal, while all standard output is discarded. Which command achieves this?
Which of the following is NOT a typical reason for using threads instead of processes?
Which of the following is NOT a typical reason for using threads instead of processes?
What is the primary advantage of separating fork()
and exec()
system calls?
What is the primary advantage of separating fork()
and exec()
system calls?
Which of the following is a key characteristic that distinguishes pthreads
from clone()
?
Which of the following is a key characteristic that distinguishes pthreads
from clone()
?
Which of the following is the most accurate description of the role of the OS kernel in managing hardware resources?
Which of the following is the most accurate description of the role of the OS kernel in managing hardware resources?
Consider a system using preemptive multitasking. What mechanism does the OS primarily rely on to regain control from a running user program?
Consider a system using preemptive multitasking. What mechanism does the OS primarily rely on to regain control from a running user program?
Which of the following is the most significant drawback of using swapping as a memory management technique, compared to paging?
Which of the following is the most significant drawback of using swapping as a memory management technique, compared to paging?
In the context of memory allocation, what is the key difference between static and stack allocation?
In the context of memory allocation, what is the key difference between static and stack allocation?
Which of the following scheduling algorithms could lead to starvation?
Which of the following scheduling algorithms could lead to starvation?
Flashcards
Process
Process
A program running with its own PID, memory, and state.
Process States
Process States
New, Ready, Running, Waiting, and Terminated.
Code Segment
Code Segment
Stores executable instructions.
User ID (UID)
User ID (UID)
Signup and view all the flashcards
Library Calls
Library Calls
Signup and view all the flashcards
System Calls
System Calls
Signup and view all the flashcards
Environment Variables
Environment Variables
Signup and view all the flashcards
Internal Commands
Internal Commands
Signup and view all the flashcards
Resource Management & Abstraction
Resource Management & Abstraction
Signup and view all the flashcards
Preemptive Multitasking
Preemptive Multitasking
Signup and view all the flashcards
Monolithic Kernel
Monolithic Kernel
Signup and view all the flashcards
Microkernel
Microkernel
Signup and view all the flashcards
FUSE/udev/sshfs
FUSE/udev/sshfs
Signup and view all the flashcards
OS User Interfaces
OS User Interfaces
Signup and view all the flashcards
Kernel Mode (Ring 0)
Kernel Mode (Ring 0)
Signup and view all the flashcards
Processes & PIDs
Processes & PIDs
Signup and view all the flashcards
init (PID 1)
init (PID 1)
Signup and view all the flashcards
Zombie Process
Zombie Process
Signup and view all the flashcards
Signals
Signals
Signup and view all the flashcards
sigaction()
sigaction()
Signup and view all the flashcards
Shell Pipeline (|)
Shell Pipeline (|)
Signup and view all the flashcards
Absolute Pathname
Absolute Pathname
Signup and view all the flashcards
open()
open()
Signup and view all the flashcards
Mounting
Mounting
Signup and view all the flashcards
Limited Direct Execution
Limited Direct Execution
Signup and view all the flashcards
Execution Context
Execution Context
Signup and view all the flashcards
Context Switch
Context Switch
Signup and view all the flashcards
OS Scheduling
OS Scheduling
Signup and view all the flashcards
fork() System Call
fork() System Call
Signup and view all the flashcards
exec() System Call
exec() System Call
Signup and view all the flashcards
Threads
Threads
Signup and view all the flashcards
Paging
Paging
Signup and view all the flashcards
Data Recovery Tools
Data Recovery Tools
Signup and view all the flashcards
Device Repair
Device Repair
Signup and view all the flashcards
Special File Systems
Special File Systems
Signup and view all the flashcards
User-Space File Systems
User-Space File Systems
Signup and view all the flashcards
External Fragmentation
External Fragmentation
Signup and view all the flashcards
Shell Features
Shell Features
Signup and view all the flashcards
/dev/stdin, /dev/stdout, /dev/stderr
/dev/stdin, /dev/stdout, /dev/stderr
Signup and view all the flashcards
Linux Login Process
Linux Login Process
Signup and view all the flashcards
/etc/passwd
/etc/passwd
Signup and view all the flashcards
/etc/passwd fields
/etc/passwd fields
Signup and view all the flashcards
Environment
Environment
Signup and view all the flashcards
Common Environment Variables
Common Environment Variables
Signup and view all the flashcards
Modifying Environment Variables
Modifying Environment Variables
Signup and view all the flashcards
Study Notes
Resource Management & Abstraction
- The OS manages hardware resources, including the CPU, RAM, and storage
- Abstraction simplifies hardware complexities, aiding program interaction with resources without detailed knowledge
Benefits of Abstraction
- Programs become portable, running on different hardware platforms without changes
- Security is enhanced as abstraction restricts direct hardware access, thus mitigating risks
- Resource allocation is optimized dynamically by the OS, improving efficiency
Preemptive Multitasking
- The OS can interrupt a process, switching to another to ensure fair CPU usage
- Multi-user environments are enabled, preventing a single program from monopolizing resources
Monolithic Kernel
- Everything, including device drivers, memory management, and file systems, operates in kernel mode (Ring 0)
- Faster execution and fewer context switches can occur
- Less modular architecture means a single failure can crash the entire system
Microkernel
- Only essential functions like IPC, scheduling, and memory operate in kernel mode
- Other services, such as device drivers and file systems, run in user space
- More modular and secure design means failures are less likely to crash the entire system
- Slower than monolithic kernels due to more IPC overhead
FUSE/udev/sshfs
- These exemplify moving services to user space, similar to microkernel designs
- FUSE (Filesystem in Userspace) enables users to create custom file systems without kernel modifications
- udev manages device nodes dynamically in user space
- sshfs facilitates remote file system mounting over SSH without kernel modifications
Command-Line, Text UI, GUI
- Different ways for users to interact with the OS exist
- Command-line interfaces are powerful and scriptable, but have a learning curve
- Text UIs are menu-based, such as
ncurses
programs likehtop
- GUIs are graphical desktops that are user-friendly but require more resources
Kernel Mode (Ring 0) vs. User Mode
- Kernel Mode (Ring 0) has full access to the hardware
- Critical OS functions like memory management and device drivers run in Kernel mode
- User Mode access is restricted and can only use system calls to interact with hardware
- User Mode protects system stability by preventing direct hardware access
- CPUs enforce separation using privilege levels
Processes and PIDs
- A process is a running instance of a program
- A PID (Process ID) is a unique identifier assigned by the OS
- Program binaries such as
/bin/ls
are just files - When a program binary is executed, it becomes a process with its own PID, memory, and state
Process Lifecycle and Symbols
- Process states include New, Ready, Running, Waiting (I/O), and Terminated
- Symbols represent different states in tools like
ps
(e.g., R for running, S for sleeping)
Address Space Layout
- Each process has a virtual address space
- The code segment stores executable instructions
- The data segment stores global/static variables
- The heap is used for dynamic memory (e.g.,
malloc
in C) - The stack is used for function calls and local variables
Argv/env
is used to store command-line arguments and environment variables
Users and UIDs
- Every user has a UID (User ID)
- Root (UID = 0) has full control over the system
- A UID is a software label, not hardware-enforced, but controlled by the OS
Files and File Systems
- A file is the basic unit of data storage
- A file system is a structure that organizes files
- File systems provide abstraction for storage devices such as HDDs, SSDs, and USB drives
Library Calls vs. System Calls
- Library calls (lib calls) are functions provided by libraries (e.g.,
printf()
,malloc()
) - System calls (sys calls) are direct OS requests (e.g.,
open()
,read()
,write()
) - Lib calls run in user space.
- Sys calls require a switch to kernel space.
Abstraction and Portability
- Higher-level abstractions make software more portable across different OS/hardware
- Code written in C is more portable than assembly code because C offers higher abstraction
Environment Variables
- Environment variables are key-value pairs stored in the shell/process environment
- Environment variables are used for configuration
- Variables can be global, available to all child processes or local, only for the current shell
Internal vs. External Commands
- Internal (built-in) commands are executed directly by the shell
- External commands are separate binaries stored in system directories
- Internal commands are generally faster
Execution Types
- Direct execution runs code directly on the CPU
- Indirect execution requires an interpreter
- Limited direct execution allows user programs to run but enforces control using interrupts
Execution Context and Context Switching
- The execution context is the state of a process
- A context switch occurs when the CPU switches from one prcoess to another
- Context switching involves saving and restoring registers so it's expensive
Scheduling and Principles
- The OS determines which process/thread gets CPU time based on scheduling policies
- Common scheduling strategies include FIFO, Round Robin, Priority Scheduling and Multilevel Queue
fork()
and exec()
fork()
creates a new process by duplicating the parentexec()
replaces the process memory with a new program- Using separate calls provides flexibility, allows child processes to modify their state, and enables parallel execution
Threads vs. Processes
- Processes have separate memory spaces
- Threads within a process share memory (stack, heap)
- Faster context switching is a benefit of threads
- Threads can lead to easier communication, but also risk race conditions
pthreads
vs. clone()
pthreads
is a high-level API for threading that works across different OS implementationsclone()
is a low-level system call that creates a process or thread, offering more control but is harder to use
Paging and Swapping
- Paging divides memory into fixed-size pages
- Virtual memory is mapped to physical memory using a page table.
- Swapping moves entire processes from RAM to disk when memory is full
Role of the Kernel in Abstraction
- Provides a simplified interface for hardware (CPU, memory, I/O)
- Manages execution, handles memory, and controls access
Memory Allocation and Symbols
- Memory allocation can be static (compile time), stack (runtime), or heap (runtime)
- Symbols represent functions, variables, etc. in compiled programs
- Some symbols exist only at compile-time, others at runtime.
Libcall vs. Syscall
- Lib calls call functions from libraries and run in user mode.
- Syscalls directly request OS services, triggering a context switch into kernel mode.
Consequences
- Lib calls are faster but syscalls have more overhead but direct hardware access.
Compile-time Libraries
- Loaded and linked at compile time
Load-time Libraries
- Dynamically linked to shared libraries at load time.
Library Usage
- Syscall transitions occur at runtime during actual execution, and transition to kernel mode.
Steps for Talking to a Computer
- Terminal
/sbin/getty
starts when a terminal is opened and waits for a login - Login
/usr/bin/login
handles user authentication /etc/passwd
and/etc/shadow
are read for credentials After Login- Shell
/bin/bash
will start - The custom shell, like 3000shell, interprest the user commands.
User Account Info
/etc/passwd
- Stores usernames, UIDs, GIDs, home directories, and shell paths.
/etc/shadow
- Stores hashed passwords for security.
UID, EUID, GID, EGID, setuid
- Identifies users UID (User ID):
- Identifies a user. EUID (Effective UID):
- Determines actual privileges.
If a program has setuid enabled:
- It can run with elevated privileges (e.g., sudo). GID (Group ID), EGID (Effective GID):
- Same as UID, but for groups.
File Permision bits & Notation Conversion
Octal Notation
rwxr-xr--→ 754
Owner = rwx=7, Group = r-x=5, Others= r--=4. Symbolic notationchmod u+x file → Adds
execute permission to the user
Special Bits
setuid (chmod u+s)
Runs as the files ownersetgid (chmod g+s)
Runs with the group's permissions.Sticky_bit (chmod +t)
Only the owner can delete files in directory.
Workflow of a shell
- Reads input (command line)
- Parses and tokenizes commands
- Expands wildcards and variables
- Determines if it's built-in or external commands
- If external, it forks a child proces
- Uses exec() to replace process memory with command
- Waits for process completion
Init (PID 1) - Before any user process
- First process started by kernel
- Manages system initialization and background service
- Modern systems use Systemd. SysV init or openRC
Zombie State & Reaping
Zombie process
- A process that has finished executing but still has an entry in the process table
- Happens if the parents does notcall wait() to clean up
Reaping The OS (or parent process) removes zombie when wait() is called
Signals & Concurrency Issues
- Signals - Asynchronous notifications sent to processes
- Predefined, no payload-- Cannot send extra dta, only a signal number.
- Concurrency Issue-- if a signel is sent beffore a process si ready, it might get lost.
DA-RESTART
--- ensures internrupted system calls are retired instead of failing.
Signal Handling [signaction())] Sending Signals (kill())
sigaction()
Sets a signal handler for a processkill(pid, SIGTERM)
Sends a termination signal to a process
Shell Pipeline (|) & redirection (<, >, >>)
Pipeline (|)
- Chains commands together by passing
stdout
of one to stdin of next.. - Example -
cat file.txt |grep "error" | wc -1
Redirection
< file Reads
input froma file> file
overwites a file with output>> file
appends output.
Ways to provide input
- Command line Args --- ./scrip arg1 arg2
- Piped input-- Echo "hello" | my program
- Files--- my program < input.txt
- Standard input (stdin) --- Reads input dynamically.
Path, Pathname, Flilame
- Path --- Location of the file
- Filename- the name of a fil - w/out file path
- Absolute path name- Full path to the root
- Relative Pathname--- based on current
Ioctl() - Sends control command to devices (change terminal settings). Monting a File System
- Attaching a file system(USB)
- Mount /dev/SDB111 /mnt/USB - monts the device /mnt/Use Checks if directory is mount Pion - Mountpoint
The Shell
- A command line interpreter that allows users to interact with the OS
- Bash ZSH, Fish, SH
- Executes internal commands and external commands
- Provides features like vars, scripting, pipes, redirection, and job control
Standard input,output or error streams
Login Process
Getly
start and displays a login prompt
User Account info
- Contains basic user info but not password
Format
- usernamex:un/gid Examples
A shell
- the enviornment consits od vars the fact shell processes
Ram Vs Storages
RAM-FAst Votatile Storage IO Operations refer to reading /writing data between RAM and storage.
Block Device Layer & Block Size
- Storage is managed in blocks the Smallest unit of disk I/O
- The Block device layer abstract Hardware Differnces and allows buffering of Read/Wiite Operations
File types & inodes File types::
Regular files, directories, symbolic links, device files, sockets, FIFOs Stores Medata About files
File descriptor
- per process fils decrptio
- process tacks openfiles y insing intager ID
File System & device files
Special files
- exist only in VFS (Virtual File System) Not an the physicial disk
Device files
- Are stored in /Dev and reperesnt Hadware.
Dev Files,Logical Size
The amount of data a file contains; - logical file
Actural space the file occupy's on disl: - Physical fire
.
- If 7> 0 ,the files Sparse(contains "holes")
- If O>7, disk fragmentation Or Compressin may be involvedi *
Files system cresh Consistency & Recovery
- System Crash Consiatancy - Ensuting data interity after chashes
- method Recory
Specail File Systems
- special file systems - OS- Information
- User -Spaces file Systems ALLoc implimenting custom
External Vs Internal Fragmentition
External F:
- Free space is split into small, unusable Chunks
- Intenall - un used
memory Vs Storage Alloaition
Memroy - Usises pages(files Sized unis,typicall by +kb)
- Storage - Uses - Blocks (also files, size Vary's by file system). dynamic Us Static Lnking
- Static linking - All depencies die induiled in the binary (larger Sizs, independent) dynamic lnking - The program loads shared libraries at runtime (Smaller, by depends On System libraries),
Per-Process Properties
Each process has:
- Enviorn ment variaables - Env, home, $path, ete
- Filse discipters - open files, pipes sockets
Current working directory CWD - Determines ivelative path behavior
Readiny commaand output
- Standy Commande Outputo - like ds stan de du. etc- Melps diagroner file syshemen And Storage isrues.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Explore key OS concepts: abstraction, preemptive multitasking, kernel architectures, and the user/kernel mode distinction. Understand process states, memory management, user IDs and the difference between hard and symbolic links.