1/49
Fifty vocabulary flashcards covering memory segments, process creation, file descriptors, pipes, sockets, threads, and related OS concepts
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Text (Code) Segment
Memory area that stores machine instructions; usually read-only and fixed for the life of the program.
Data Segment
Section holding global and static variables that are explicitly initialized by the programmer before program start.
BSS Segment
Memory segment that contains uninitialized global and static variables; the loader zero-fills it at program start.
Stack Segment
LIFO region used for function call frames, local variables, parameters, and return addresses.
Heap
Dynamically managed memory area obtained with malloc/new and released with free/delete.
Uninitialized Global Variable
Global or static variable with no explicit initializer; stored in BSS and auto-initialized to zero.
Initialized Global Variable
Global or static variable that receives an explicit value at declaration; stored in the data segment.
Undefined Behavior (UB)
Result of executing code for which the C/C++ standard imposes no requirements, such as out-of-bounds access or null dereference.
File Descriptor (FD)
Integer handle that the kernel uses to identify an open file, pipe, socket, or device.
Standard Input (stdin)
Pre-opened file descriptor 0 used for program input, typically connected to keyboard or a pipe.
Standard Output (stdout)
Pre-opened file descriptor 1 used for normal program output, usually connected to terminal or a pipe.
Standard Error (stderr)
Pre-opened file descriptor 2 for error messages; separate from stdout so errors can be redirected independently.
freopen()
C library call that closes an existing FILE* stream and reopens it on a new file, enabling redirection of stdin, stdout, or stderr.
fork()
System call that creates a new process by duplicating the calling process; returns twice, once in parent, once in child.
Child Process PID Return Value
Value returned by fork() to the newly created child; always 0, allowing branch differentiation.
fork() Failure Return Value
Negative return (-1) from fork() indicating process creation failed; errno holds the error cause.
Process Count After fork()
Each successful fork doubles the number of running processes; n forks yield 2^n processes.
dup()
System call that duplicates an existing file descriptor to the lowest unused number, pointing to the same open file description.
dup2()
System call that duplicates oldfd onto a specified newfd, closing newfd first if necessary.
Pipe Read End
Index 0 of the int array returned by pipe(); used exclusively for reading data.
Pipe Write End
Index 1 of the int array returned by pipe(); used exclusively for writing data.
Named Pipe (FIFO)
Special file on the filesystem that provides pipe semantics between unrelated processes using a known pathname.
mkfifo()
Command/system call that creates a named pipe (FIFO) node in the filesystem.
execvp()
exec-family function that replaces the current process image with a new program, searching PATH for the executable and passing an argument vector.
socket() System Call
Creates an endpoint for network communication, returning a file descriptor representing a socket.
bind() System Call
Associates a socket with a local address (IP and port); required on the server side before listening.
listen() System Call
Marks a bound socket as passive, ready to accept incoming connection requests (TCP).
accept() System Call
Extracts the first pending connection on a listening socket and returns a new socket for data exchange.
connect() System Call
Initiates a connection from a client socket to a remote server address and port.
SOCK_STREAM
Socket type constant indicating a reliable, connection-oriented byte stream, typically TCP.
Loopback Address
IP address 127.0.0.1 used for network communication within the same host.
pthread_create()
POSIX thread API that spawns a new thread of execution, immediately starting the specified function.
pthread_join()
Blocks the calling thread until the specified thread terminates, optionally retrieving its exit status.
Header file that declares POSIX threading APIs such as pthreadcreate, pthreadmutex, and pthread_join.
-pthread Compile Flag
GCC/Clang option that links the pthread library and defines required macros for multithreading.
Critical Section
Code region that accesses shared resources and must execute by only one thread at a time to maintain consistency.
Mutex
Synchronization primitive (mutual exclusion lock) used to protect critical sections against concurrent access.
Copy-on-Write
Optimization where a child process shares physical pages with the parent after fork() until one modifies a page.
Heap vs Stack Isolation
Each process has its own private heap and stack; they are not shared between separate processes.
Preemptive Multitasking
OS scheduling model where the kernel can interrupt running tasks to allocate CPU time fairly among processes and threads.
Platform as a Service (PaaS)
Cloud computing model that delivers hardware and software tools over the internet to host, build, and deploy applications without managing infrastructure.
fork() Child Return Value Equals 0
Design detail enabling if-statements to distinguish child execution path using the zero value from fork().
Parent Return Value of fork()
Value returned to the parent process by fork(); it is the PID of the newly created child, never 0 on success.
Pipe Blocking Behavior
Unnamed pipes can cause open() or read()/write() calls to block until the opposite end is opened or has data.
Sockets vs Pipes IPC
Sockets support local and network communication, whereas unnamed pipes require parent-child relationship and share only local memory.
TCP vs UDP
TCP provides reliable, ordered delivery (SOCKSTREAM); UDP (SOCKDGRAM) offers connectionless, best-effort delivery.
LIFO Allocation
Stack memory management strategy where the last function called is the first to return, mirroring push/pop behavior.
Dynamic Memory Allocation
Runtime acquisition of memory from the heap using malloc/new, requiring explicit release with free/delete.
Global Variable Lifetime
Global and static variables in data or BSS segments exist for the entire lifetime of the program unless explicitly freed (heap allocation).
Number of Processes After n forks
General rule: executing n independent fork() calls results in 2 raised to the power of n separate processes.