Systems Programming Exam 1

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/180

flashcard set

Earn XP

Description and Tags

Systems Programming - Aubrey Knight

Last updated 5:36 PM on 9/22/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

181 Terms

1
New cards
What is systems programming?
The knowledge and skillset required to write/modify an operating system OR write programs using an OS's API.
2
New cards
Which definition of systems programming is emphasized in this course?
Writing programs using a UNIX-like OS API.
3
New cards
Why use a UNIX-like OS for systems programming?
Simplicity, exposure, and availability.
4
New cards
What does POSIX stand for?
Portable Operating Systems Interface.
5
New cards
What standard defines common UNIX-like OS features?

POSIX (part of SUSv4)

6
New cards
What is the kernel?
The central software that manages and allocates computer resources.
7
New cards
What is the shell?
A command interpreter that reads user commands and executes programs.
8
New cards
Examples of shells?
sh, csh, ksh, bash.
9
New cards
What is a user?
An individual system account identified by a username and user ID.
10
New cards
What is a group?
A category of users identified by a group name and group ID.
11
New cards
What is meant by a single directory hierarchy?
All files and directories are accessed from one root directory.
12
New cards
What is the root directory in UNIX-like systems?
/
13
New cards
What file types exist in UNIX-like systems?
Regular, device, FIFO, socket, directory, symbolic link.
14
New cards
What is universality of I/O?
All file types use the same basic I/O system calls.
15
New cards
Four basic I/O system calls?
open, read, write, close.
16
New cards
What is a process?
An instance of an executing program.
17
New cards
What information does the kernel track about a process?
User, PID, termination status, parent process.
18
New cards
Major regions of a process's memory?
Text, globals/statics, heap, stack.
19
New cards
What is memory mapping?
Mapping a file or memory region into a process's virtual address space.
20
New cards
What is file mapping?
Mapping a file into virtual memory.
21
New cards
What is anonymous mapping?
Memory mapping without an associated file, initialized to zero.
22
New cards
What is IPC?
Interprocess Communication.
23
New cards
Examples of IPC mechanisms?
Signals, pipes, sockets, file locking, message queues, semaphores, shared memory.
24
New cards
What are signals?
Kernel-generated notifications of events or exceptional conditions.
25
New cards
Why are signals called software interrupts?
They interrupt normal program execution.
26
New cards
Examples of signal-generating events?
Ctrl-C, child termination, timer expiration, divide by zero, invalid memory access.
27
New cards
What is a thread?
A lightweight execution unit within a process.
28
New cards
What do threads share?
Code, global data, heap, virtual memory.
29
New cards
What do threads not share?
Their execution stacks.
30
New cards
What is a system call?
A controlled entry point into the kernel.
31
New cards
Why are system calls necessary?
Some actions must be performed by the kernel.
32
New cards
Examples of kernel services?
Process creation, IPC creation, I/O processing, file systems.
33
New cards
What is the universal I/O model?
The same basic I/O system calls work on all file types.
34
New cards
What is a file descriptor?
A small non-negative integer representing an open file.
35
New cards
What does file descriptor 0 represent?
Standard input.
36
New cards
What does file descriptor 1 represent?
Standard output.
37
New cards
What does file descriptor 2 represent?
Standard error.
38
New cards
What does open() do?
Opens a file and returns a file descriptor.
39
New cards
What does read() do?
Reads bytes from a file into a buffer.
40
New cards
What does write() do?
Writes bytes from a buffer to a file.
41
New cards
What does close() do?
Closes a file descriptor and releases resources.
42
New cards
Prototype of open()?
int open(const char *path, int flags, mode_t mode)
43
New cards
Success return value of open()?
File descriptor >= 0.
44
New cards
Failure return value of open()?
-1.
45
New cards
What does O_RDONLY mean?
Open file for reading only.
46
New cards
What does O_WRONLY mean?
Open file for writing only.
47
New cards
What does O_RDWR mean?
Open file for reading and writing.
48
New cards
What does O_CREAT do?
Create file if it doesn't exist.
49
New cards
What does O_TRUNC do?
Truncate existing file.
50
New cards
What does O_APPEND do?
Append writes to end of file.
51
New cards
What is mode used for in open()?
File permissions when creating a file.
52
New cards
What does S_IRUSR mean?
User read permission.
53
New cards
What does S_IWUSR mean?
User write permission.
54
New cards
What does S_IXUSR mean?
User execute permission.
55
New cards
What does S_IRGRP mean?
Group read permission.
56
New cards
What does S_IWGRP mean?
Group write permission.
57
New cards
What does S_IXGRP mean?
Group execute permission.
58
New cards
What does S_IROTH mean?
Other read permission.
59
New cards
What does S_IWOTH mean?
Other write permission.
60
New cards
What does S_IXOTH mean?
Other execute permission.
61
New cards
What does errno store?
Error information for failed system calls.
62
New cards
ENOENT?
File does not exist.
63
New cards
EACCES?
Permission denied.
64
New cards
EMFILE?
Process has no more file descriptors available.
65
New cards
ENFILE?
System-wide open file limit reached.
66
New cards
EROFS?
Write attempted on read-only filesystem.
67
New cards
What is blocking I/O?
The process waits until the resource becomes available.
68
New cards
What is non-blocking I/O?
The process continues immediately if resource is unavailable.
69
New cards
Prototype of read()?
ssize_t read(int fd, void *buffer, size_t count)
70
New cards
What does read return on EOF?
0.
71
New cards
What does read return on error?
-1.
72
New cards
Prototype of write()?
ssize_t write(int fd, const void *buffer, size_t count)
73
New cards
What does write return?
Number of bytes written or -1 on error.
74
New cards
Prototype of close()?
int close(int fd)
75
New cards
What does close return on success?
0.
76
New cards
What is a file system?
An organized collection of files and directories.
77
New cards
What is a disk partition?
A non-overlapping region of a disk treated as a device.
78
New cards
What are device special files?
Files that represent hardware devices.
79
New cards
Types of device special files?
Character devices and block devices.
80
New cards
Examples of file systems?
ext2, ext3, ext4, XFS, FAT32, NTFS, HFS.
81
New cards
What is a logical block?
The basic unit for allocating space in a file system.
82
New cards
What is the boot block?
The first filesystem block containing boot information.
83
New cards
What is the superblock?
Filesystem metadata including size and layout.
84
New cards
What is an inode?
A structure storing metadata about a file.
85
New cards
What metadata does an inode store?
Type, owner, permissions, timestamps, size, links, block pointers.
86
New cards
What is stat()?
Retrieves file metadata.
87
New cards
Difference between stat() and fstat()?
fstat() uses a file descriptor.
88
New cards
What structure stores file metadata?
struct stat.
89
New cards
What member stores file type and permissions?
st_mode.
90
New cards
What member stores file size?
st_size.
91
New cards
What member stores inode number?
st_ino.
92
New cards
What member stores owner UID?
st_uid.
93
New cards
What member stores owner GID?
st_gid.
94
New cards
What are the three UNIX permission categories?
User, Group, Other.
95
New cards
What are the three permission bits?
Read, Write, Execute.
96
New cards
What does permission 644 mean?
User rw-, Group r--, Other r--.
97
New cards
What does S_IRWXU mask?
All user permission bits.
98
New cards
What does S_IRWXG mask?
All group permission bits.
99
New cards
What does S_IRWXO mask?
All other permission bits.
100
New cards
How is file type extracted from st_mode?
st_mode & S_IFMT