









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Linked list head - answer- Pointer to the first node in the list Linked list tail - answer- Last node in the list usually points to NULL Singly linked list node - answer- Data and next pointer Doubly linked list node - answer- Data next pointer prev pointer Circular singly linked list - answer- Last node points back to head instead of NULL Circular doubly linked list - answer- Last node next points to head and head prev points to tail Why linked lists are different from arrays - answer- Order is determined by pointers not indexes Linked list traversal - answer- Moving through nodes one by one using pointers If head is NULL - answer- Linked list is empty
Typology: Exams
1 / 16
This page cannot be seen from the preview
Don't miss anything!










Linked list head - answer- Pointer to the first node in the list Linked list tail - answer- Last node in the list usually points to NULL Singly linked list node - answer- Data and next pointer Doubly linked list node - answer- Data next pointer prev pointer Circular singly linked list - answer- Last node points back to head instead of NULL Circular doubly linked list - answer- Last node next points to head and head prev points to tail Why linked lists are different from arrays - answer- Order is determined by pointers not indexes Linked list traversal - answer- Moving through nodes one by one using pointers If head is NULL - answer- Linked list is empty Why professor gives linked list questions - answer- To trace output not write full code fork() - answer- Creates a child process that is almost identical to the parent Return value of fork in parent - answer- Child PID
Return value of fork in child - answer- 0 Return value of fork on failure - answer- - Parent and child after fork - answer- Run concurrently and execution order can vary exec() - answer- Replaces current process image with a new program fork plus exec - answer- Common way to create and run a new program wait() - answer- Makes parent pause until child finishes Why use wait() - answer- Prevents zombie processes Zombie process - answer- Process finished but parent has not collected exit status Orphan process - answer- Child whose parent terminated before child Who adopts orphan process - answer- init or systemd init/systemd - answer- PID 1 first process and adopts orphans Infinite loop plus Ctrl+C - answer- Sends SIGINT signal Ctrl+C signal - answer- SIGINT
PPID - answer- Parent Process ID TTY - answer- Terminal controlling the process CMD - answer- Command that started the process TIME - answer- CPU time used by process How to find parent process - answer- Check PPID and match parent PID Process graph output - answer- Output depends on scheduling order after fork Guaranteed output before fork - answer- Statements before fork always print first After fork output - answer- Order may vary because parent and child run concurrently Why multiple outputs possible after fork - answer- Process scheduling is nondeterministic Thread - answer- Smallest unit of execution inside a process Process vs thread - answer- Process has own memory threads share process memory Why threads are faster than processes - answer- Context switching is faster and shared memory exists Main multithreading danger - answer- Race conditions
Race condition - answer- Two threads modify shared data at same time causing wrong output Shared variable danger - answer- Counter may become incorrect Critical section - answer- Code only one thread should execute at a time Mutex lock - answer- Mutual exclusion lock protecting critical section pthread_mutex_t - answer- Data type for mutex pthread_mutex_init() - answer- Initializes mutex pthread_mutex_lock() - answer- Attempts to acquire lock pthread_mutex_unlock() - answer- Releases lock pthread_mutex_destroy() - answer- Destroys mutex after use Where to place mutex - answer- Around shared variable updates inside critical section Why mutex needed - answer- Prevents race conditions and ensures correct output Counter with synchronization - answer- Correct total increments from all threads Counter without synchronization - answer- Can produce many wrong answers
Scheduling occurs when - answer- Process waits process becomes ready process ends process preempted Preemptive scheduling - answer- OS can interrupt running process Nonpreemptive scheduling - answer- Process keeps CPU until waiting or termination Nonpreemptive issue - answer- CPU monopolization Preemptive issue - answer- Race conditions and synchronization problems FCFS scheduling - answer- First Come First Serve FCFS type - answer- Nonpreemptive FCFS weakness - answer- Long jobs can make short jobs wait too long Convoy effect - answer- Short jobs wait behind one long job SJF scheduling - answer- Shortest Job First Preemptive SJF - answer- Shortest remaining time first Why SJF is good - answer- Usually gives lowest average waiting time Gantt chart - answer- Visual timeline of process scheduling
Waiting time - answer- Time process spends waiting in ready queue Turnaround time - answer- Arrival to completion total time Response time - answer- Time until first response Throughput - answer- Processes completed per unit time CPU utilization - answer- Keeping CPU busy as much as possible Average waiting time formula - answer- Total waiting times divided by number of processes CPU burst prediction formula - answer- T(n+1)=αt(n)+(1-α)T(n) Predicted burst T(n) - answer- Previous estimate Actual burst t(n) - answer- Real measured CPU burst Alpha range - answer- Between 0 and 1 High alpha means - answer- Recent actual burst matters more Low alpha means - answer- Previous prediction matters more Process - answer- A program in execution
ulimit -u - answer- Check max processes user can create cat /proc/sys/kernel/pid_max - answer- Check max process table size Control flow - answer- Order CPU executes instructions Simplest control flow - answer- Straight line sequential execution Control transfer - answer- Change in normal execution flow Exceptional Control Flow (ECF) - answer- Sudden change due to system event Examples of ECF - answer- Divide by zero Ctrl+C timer interrupt disk input Exception - answer- Transfer of control to OS kernel Exception table - answer- Jump table used to locate exception handlers Exception number - answer- Index used to locate handler Interrupt - answer- Asynchronous hardware event Trap - answer- Intentional exception like system call Fault - answer- Potentially recoverable issue
Abort - answer- Fatal unrecoverable issue Interrupt returns to - answer- Next instruction Trap returns to - answer- Next instruction Fault returns to - answer- Current instruction after fix Abort returns to - answer- Usually does not return program ends Divide by zero example - answer- Exception Invalid memory access example - answer- Fault often segmentation fault Segmentation fault signal - answer- SIGSEGV Function pointer - answer- Pointer that stores address of a function Why parentheses needed in function pointer - answer- Without them compiler thinks it is function returning pointer Function pointer use - answer- Runtime flexibility callbacks polymorphism Polymorphism in C - answer- Using same interface with different function behavior Struct - answer- User-defined type grouping variables
Enum custom values - answer- Can manually assign numbers Enum after custom value - answer- Next continues from assigned value plus one Why enums are better than define - answer- Type safety grouping readability /etc/passwd - answer- Stores user account information /etc/shadow - answer- Stores encrypted passwords Why passwords moved to shadow - answer- Security and prevent easy cracking Fields in /etc/passwd - answer- Username password placeholder UID GID info home directory shell UID - answer- User ID GID - answer- Group ID GECOS - answer- Human readable user information adduser - answer- More helpful wrapper for creating users useradd - answer- Basic command to add users passwd command - answer- Changes password
chmod - answer- Changes permissions chmod +x - answer- Add execute permission 777 permissions - answer- Read write execute for everyone 666 permissions - answer- Read write for everyone 444 permissions - answer- Read only for everyone Shebang - answer- #! followed by interpreter path Why shebang matters - answer- Tells operating system what program runs script Example shebang - answer- #!/bin/bash Hash without exclamation - answer- Comment in shell script Makefile - answer- File used to automate compilation Makefile main benefit - answer- Only changed files are recompiled Linking - answer- Combining code and data from multiple files into one executable When linking happens - answer- Compile time load time runtime
Global symbol - answer- Can be referenced by other modules Local symbol - answer- Only visible inside current module External symbol - answer- Referenced here but defined elsewhere Strong symbol - answer- Initialized global variable Weak symbol - answer- Uninitialized global variable Rule 1 duplicate symbols - answer- Multiple strong symbols gives linker error Rule 2 duplicate symbols - answer- One strong and one weak use strong Rule 3 duplicate symbols - answer- Multiple weak linker chooses one ELF - answer- Executable and Linkable Format Purpose of ELF - answer- Standard format for executables object files shared libraries