Flashcard Deck · 20 cards · Public

COMP2017 - Systems Programming in C

Master low-level C programming, POSIX system calls, memory management, and multi-threaded concurrency with this high-yield COMP2017 flashcard deck.

Cards in this deck

(20 cards)

Preview terms and definitions before starting your study session.

#1
Term
Pointer Arithmetic with Typed Pointers
Definition
Adding to a pointer increments its memory address by bytes. For example, if int *p points to address 0x1000 (assuming 4-byte int), p + 1 yields 0x1004, whereas for a char *p, p + 1 yields 0x1001.
#2
Term
malloc() vs. calloc()
Definition
  • malloc(size_t size): Allocates size bytes of uninitialized memory containing garbage values.
  • calloc(size_t num, size_t size): Allocates memory for num objects of size bytes each and initializes all bits to 0.
#3
Term
Struct Padding and Data Alignment
Definition
Compilers insert unallocated byte gaps (padding) inside structs so fields align with processor memory boundaries (typically multiples of member size). Consequently, sizeof(struct) is often greater than the sum of the individual sizes of its members.
#4
Term
Process Creation with fork()
Definition
fork() duplicates the calling process to create a child process. It returns:
  • 0 inside the child process.
  • The child's Process ID (PID) inside the parent process.
  • -1 on error.
#5
Term
Zombie vs. Orphan Processes
Definition
  • Zombie Process: A child process that has finished execution but whose parent has not yet read its exit status via wait()/waitpid().
  • Orphan Process: A running child whose parent process has died; it is automatically adopted by init (PID 1).
#6
Term
The exec() Family of System Calls
Definition
Replaces the current process execution image (code, heap, stack, data) with a new program image. On success, exec() does not return because the calling code image no longer exists; the PID remains unchanged.
#7
Term
Inter-Process Communication with pipe()
Definition
int pipe(int pipefd[2]) creates a unidirectional data channel stored in the kernel.
  • pipefd[0]: Open for reading.
  • pipefd[1]: Open for writing.
Data written to pipefd[1] is buffered until read from pipefd[0].
#8
Term
Standard File Descriptors
Definition
By default, every POSIX process opens three standard file descriptors:
  • 0: Standard Input (STDIN_FILENO / stdin)
  • 1: Standard Output (STDOUT_FILENO / stdout)
  • 2: Standard Error (STDERR_FILENO / stderr)
Showing 8 of 20 cards in this deck.
Study All Now