Podcast
Questions and Answers
The software that controls the hardware resources of the computer is called the ______.
The software that controls the hardware resources of the computer is called the ______.
kernel
The shaded portion in the diagram represents the ______ that provides an interface to the kernel.
The shaded portion in the diagram represents the ______ that provides an interface to the kernel.
system calls
Applications can use both system calls and libraries of common ______.
Applications can use both system calls and libraries of common ______.
functions
The special application that provides an interface for running other applications is called the ______.
The special application that provides an interface for running other applications is called the ______.
When logging in to a UNIX system, we enter our login name followed by our ______.
When logging in to a UNIX system, we enter our login name followed by our ______.
The file that stores user login information in UNIX systems is usually /etc/______.
The file that stores user login information in UNIX systems is usually /etc/______.
In the password file entry, the numeric user ID is represented as ______.
In the password file entry, the numeric user ID is represented as ______.
Contemporary systems have moved the encrypted ______ to a different file.
Contemporary systems have moved the encrypted ______ to a different file.
The names in a directory are called ______.
The names in a directory are called ______.
The two characters that cannot appear in a filename are the slash character (/) and the ______.
The two characters that cannot appear in a filename are the slash character (/) and the ______.
A sequence of one or more filenames, separated by slashes, forms a ______.
A sequence of one or more filenames, separated by slashes, forms a ______.
A pathname that begins with a slash is called an ______.
A pathname that begins with a slash is called an ______.
Two special filenames created in every new directory are . (dot) and ______ (dot-dot).
Two special filenames created in every new directory are . (dot) and ______ (dot-dot).
The Research UNIX System restricted a filename to ______ characters.
The Research UNIX System restricted a filename to ______ characters.
For portability, POSIX.1 recommends that filenames consist of letters, numbers, period, dash, and ______.
For portability, POSIX.1 recommends that filenames consist of letters, numbers, period, dash, and ______.
A ______ pathname refers to files relative to the current directory.
A ______ pathname refers to files relative to the current directory.
The function ______ is used to read one line at a time from standard input.
The function ______ is used to read one line at a time from standard input.
The ______ character is often typed as Control-D to signal the end of input.
The ______ character is often typed as Control-D to signal the end of input.
The program uses ______ to create a new process that is a copy of the caller.
The program uses ______ to create a new process that is a copy of the caller.
In the child process, ______ is called to execute the command read from standard input.
In the child process, ______ is called to execute the command read from standard input.
To ensure that the command is executed correctly, the program replaces the newline character with a ______ byte.
To ensure that the command is executed correctly, the program replaces the newline character with a ______ byte.
The main process waits for the child process to finish using the ______ function.
The main process waits for the child process to finish using the ______ function.
If fgets returns a null pointer, the loop ______ and the process terminates.
If fgets returns a null pointer, the loop ______ and the process terminates.
To print the prompt, the program uses the ______ function.
To print the prompt, the program uses the ______ function.
The most common standard I/O function is ______.
The most common standard I/O function is ______.
The program uses the header ______ to include function prototypes for standard I/O functions.
The program uses the header ______ to include function prototypes for standard I/O functions.
The function ______ reads one character at a time from standard input.
The function ______ reads one character at a time from standard input.
The character read by getc is written using the function ______.
The character read by getc is written using the function ______.
After the last byte of input is read, getc returns the constant ______.
After the last byte of input is read, getc returns the constant ______.
An executing instance of a program is called a ______.
An executing instance of a program is called a ______.
Every process has a unique numeric identifier called the ______.
Every process has a unique numeric identifier called the ______.
The standard I/O constants stdin and stdout are defined in the ______ header.
The standard I/O constants stdin and stdout are defined in the ______ header.
The program created in the example demonstrates the functions ______ and perror.
The program created in the example demonstrates the functions ______ and perror.
When an error occurs, the program assigns the value ______ to errno to indicate 'No such file or directory'.
When an error occurs, the program assigns the value ______ to errno to indicate 'No such file or directory'.
Using ______ allows us to know which program generated an error message in a pipeline.
Using ______ allows us to know which program generated an error message in a pipeline.
In UNIX coding conventions, passing the program name to perror helps pinpoint the ______ that caused the error.
In UNIX coding conventions, passing the program name to perror helps pinpoint the ______ that caused the error.
Fatal errors have no recovery actions and require printing an error message to the user or a ______.
Fatal errors have no recovery actions and require printing an error message to the user or a ______.
System calls usually provide a minimal ______, whereas library functions often provide more elaborate functionality.
System calls usually provide a minimal ______, whereas library functions often provide more elaborate functionality.
The process control system calls (fork, exec, and ______) are usually invoked by the user's application code directly.
The process control system calls (fork, exec, and ______) are usually invoked by the user's application code directly.
Resource-related nonfatal errors include codes like EAGAIN, ENFILE, and ______.
Resource-related nonfatal errors include codes like EAGAIN, ENFILE, and ______.
The ______ library function is a common example that simplifies the invocation of system calls.
The ______ library function is a common example that simplifies the invocation of system calls.
Shared resources being in use can lead to the ______ error being treated as nonfatal.
Shared resources being in use can lead to the ______ error being treated as nonfatal.
The typical recovery action for a resource-related nonfatal error is to delay and ______ later.
The typical recovery action for a resource-related nonfatal error is to delay and ______ later.
The ______ library function is often used as a programmer-friendly alternative to the sbrk system call.
The ______ library function is often used as a programmer-friendly alternative to the sbrk system call.
In this text, we'll use the term ______ to refer to both system calls and library functions.
In this text, we'll use the term ______ to refer to both system calls and library functions.
Each thread in a multithreaded environment requires a shared copy of errno to function correctly.
Each thread in a multithreaded environment requires a shared copy of errno to function correctly.
The value of errno can be both set to 0 and checked when a function indicates success.
The value of errno can be both set to 0 and checked when a function indicates success.
The perror function outputs an error message based on the specified string and the current value of errno.
The perror function outputs an error message based on the specified string and the current value of errno.
The function strerror(int *errnum) returns an error message string based on the value of a pointer to errnum.
The function strerror(int *errnum) returns an error message string based on the value of a pointer to errnum.
In Linux, errno is defined as a simple global integer variable accessible by all threads.
In Linux, errno is defined as a simple global integer variable accessible by all threads.
The combination of fork followed by exec is called creating a new thread.
The combination of fork followed by exec is called creating a new thread.
The waitpid function is used by the parent process to wait for the child process to finish.
The waitpid function is used by the parent process to wait for the child process to finish.
Control-D is used to signify the start of input in UNIX systems.
Control-D is used to signify the start of input in UNIX systems.
To allow arguments in the program, input lines must be parsed to separate the arguments by spaces or tabs.
To allow arguments in the program, input lines must be parsed to separate the arguments by spaces or tabs.
The child process uses execlp to execute a new program file.
The child process uses execlp to execute a new program file.
The ls command can be executed with any specified directory using the current program.
The ls command can be executed with any specified directory using the current program.
Control characters in UNIX systems are formed by pressing the normal key combinations without the control key.
Control characters in UNIX systems are formed by pressing the normal key combinations without the control key.
The termination status of the child process is ignored in the simple program mentioned.
The termination status of the child process is ignored in the simple program mentioned.
A thread ID from one process is meaningful in another process.
A thread ID from one process is meaningful in another process.
Each thread in a process executes on its own stack.
Each thread in a process executes on its own stack.
The identifier errno is set to a positive value when an error occurs.
The identifier errno is set to a positive value when an error occurs.
The open function returns -1 if an error occurs.
The open function returns -1 if an error occurs.
All functions in UNIX system return a pointer to an object to indicate an error.
All functions in UNIX system return a pointer to an object to indicate an error.
Threads can access shared data without any need for synchronization.
Threads can access shared data without any need for synchronization.
The error constant EACCES indicates a permission problem.
The error constant EACCES indicates a permission problem.
Error constants in UNIX begin with the character Z.
Error constants in UNIX begin with the character Z.
A fatal error allows for recovery actions to be taken.
A fatal error allows for recovery actions to be taken.
The error code ENOENT signifies 'No such file or directory'.
The error code ENOENT signifies 'No such file or directory'.
The perror function in C is used to print an error message associated with a specific error code.
The perror function in C is used to print an error message associated with a specific error code.
Nonfatal errors can always be ignored without consequence.
Nonfatal errors can always be ignored without consequence.
Resource-related nonfatal errors can include temporary issues like resource shortage.
Resource-related nonfatal errors can include temporary issues like resource shortage.
The statement 'EACCES: Permission denied' indicates a fatal error condition.
The statement 'EACCES: Permission denied' indicates a fatal error condition.
Using strerror, you can obtain a string message that describes the error corresponding to a specified error number.
Using strerror, you can obtain a string message that describes the error corresponding to a specified error number.
The errno variable is used to keep track of error codes for all functions in C.
The errno variable is used to keep track of error codes for all functions in C.
Ignoring a signal is recommended for hardware exceptions like dividing by zero.
Ignoring a signal is recommended for hardware exceptions like dividing by zero.
The default action for a divide-by-zero condition is to terminate the process.
The default action for a divide-by-zero condition is to terminate the process.
Catching a signal involves specifying a function to be executed when the signal occurs.
Catching a signal involves specifying a function to be executed when the signal occurs.
The quit key is typically the Control-C key.
The quit key is typically the Control-C key.
A process can send a signal to another process only if it is the owner or the superuser.
A process can send a signal to another process only if it is the owner or the superuser.
The process terminates when the SIGINT signal is generated if it has not been set to handle it differently.
The process terminates when the SIGINT signal is generated if it has not been set to handle it differently.
To generate a signal, one can only use keyboard interrupts.
To generate a signal, one can only use keyboard interrupts.
The signal function is called to handle the SIGINT signal by printing a message.
The signal function is called to handle the SIGINT signal by printing a message.
The user ID assigned to a user can be changed by the user themselves.
The user ID assigned to a user can be changed by the user themselves.
Every user in a system has a user ID that is guaranteed to be unique.
Every user in a system has a user ID that is guaranteed to be unique.
The superuser or root user has limited permissions in the operating system.
The superuser or root user has limited permissions in the operating system.
Group IDs are used to collect users into groups for resource sharing.
Group IDs are used to collect users into groups for resource sharing.
Client versions of Mac OS X come with the superuser account enabled by default.
Client versions of Mac OS X come with the superuser account enabled by default.
The group file in a system maps group names to numeric user IDs.
The group file in a system maps group names to numeric user IDs.
Exponential backoff algorithms involve waiting longer periods in each subsequent retry after an error.
Exponential backoff algorithms involve waiting longer periods in each subsequent retry after an error.
The user ID of a user who logs in is presented in the system in decimal form.
The user ID of a user who logs in is presented in the system in decimal form.
Flashcards
Operating System (OS)
Operating System (OS)
Software controlling hardware resources and enabling programs to run.
Kernel
Kernel
The core of an operating system, a small but essential software part.
System Calls
System Calls
Software layer that acts as an interface between programs and the kernel.
Login Name
Login Name
Signup and view all the flashcards
Password File
Password File
Signup and view all the flashcards
User ID (UID)
User ID (UID)
Signup and view all the flashcards
Group ID (GID)
Group ID (GID)
Signup and view all the flashcards
Shell
Shell
Signup and view all the flashcards
Filename
Filename
Signup and view all the flashcards
Invalid Filename Characters
Invalid Filename Characters
Signup and view all the flashcards
Recommended Filename Characters
Recommended Filename Characters
Signup and view all the flashcards
Special Filenames
Special Filenames
Signup and view all the flashcards
Filename Length Limit
Filename Length Limit
Signup and view all the flashcards
Pathname
Pathname
Signup and view all the flashcards
Absolute Pathname
Absolute Pathname
Signup and view all the flashcards
Relative Pathname
Relative Pathname
Signup and view all the flashcards
Standard I/O function
Standard I/O function
Signup and view all the flashcards
printf
printf
Signup and view all the flashcards
apue.h
apue.h
Signup and view all the flashcards
getc(stdin)
getc(stdin)
Signup and view all the flashcards
putc(c, stdout)
putc(c, stdout)
Signup and view all the flashcards
Process
Process
Signup and view all the flashcards
Process ID
Process ID
Signup and view all the flashcards
Program
Program
Signup and view all the flashcards
fgets Function
fgets Function
Signup and view all the flashcards
End-of-File (EOF)
End-of-File (EOF)
Signup and view all the flashcards
strlen Function
strlen Function
Signup and view all the flashcards
fork Function
fork Function
Signup and view all the flashcards
execlp Function
execlp Function
Signup and view all the flashcards
Parent Process
Parent Process
Signup and view all the flashcards
Child Process
Child Process
Signup and view all the flashcards
Waitpid Function
Waitpid Function
Signup and view all the flashcards
System Calls vs. Library Functions
System Calls vs. Library Functions
Signup and view all the flashcards
sbrk System Call
sbrk System Call
Signup and view all the flashcards
malloc Library Function
malloc Library Function
Signup and view all the flashcards
Process Control System Calls
Process Control System Calls
Signup and view all the flashcards
Library Routines (system, popen)
Library Routines (system, popen)
Signup and view all the flashcards
Fatal Error
Fatal Error
Signup and view all the flashcards
Nonfatal Error
Nonfatal Error
Signup and view all the flashcards
Resource-related error
Resource-related error
Signup and view all the flashcards
perror()
perror()
Signup and view all the flashcards
strerror()
strerror()
Signup and view all the flashcards
argv[0]
argv[0]
Signup and view all the flashcards
EACCES error
EACCES error
Signup and view all the flashcards
errno
errno
Signup and view all the flashcards
Fork-Exec Combination
Fork-Exec Combination
Signup and view all the flashcards
Spawning a Process
Spawning a Process
Signup and view all the flashcards
Control Character
Control Character
Signup and view all the flashcards
Process ID (PID)
Process ID (PID)
Signup and view all the flashcards
Arguments to a Program
Arguments to a Program
Signup and view all the flashcards
strerror(errnum)
strerror(errnum)
Signup and view all the flashcards
Why is errno important?
Why is errno important?
Signup and view all the flashcards
Why is errno thread-safe?
Why is errno thread-safe?
Signup and view all the flashcards
Threads
Threads
Signup and view all the flashcards
Thread ID
Thread ID
Signup and view all the flashcards
Thread Synchronization
Thread Synchronization
Signup and view all the flashcards
Error Handling in UNIX
Error Handling in UNIX
Signup and view all the flashcards
errno Variable
errno Variable
Signup and view all the flashcards
Error Constants
Error Constants
Signup and view all the flashcards
strerror() Function
strerror() Function
Signup and view all the flashcards
Signal
Signal
Signup and view all the flashcards
Signal Handling
Signal Handling
Signup and view all the flashcards
Default Action
Default Action
Signup and view all the flashcards
Catch a Signal
Catch a Signal
Signup and view all the flashcards
Interrupt Key
Interrupt Key
Signup and view all the flashcards
Quit Key
Quit Key
Signup and view all the flashcards
kill Function
kill Function
Signup and view all the flashcards
SIGINT
SIGINT
Signup and view all the flashcards
What is a User ID?
What is a User ID?
Signup and view all the flashcards
What is a Group ID?
What is a Group ID?
Signup and view all the flashcards
What is the root user?
What is the root user?
Signup and view all the flashcards
How are groups used?
How are groups used?
Signup and view all the flashcards
What is exponential backoff?
What is exponential backoff?
Signup and view all the flashcards
What is a fatal error?
What is a fatal error?
Signup and view all the flashcards
What is a nonfatal error?
What is a nonfatal error?
Signup and view all the flashcards
What is the purpose of the perror()
function?
What is the purpose of the perror()
function?
Signup and view all the flashcards
Study Notes
UNIX Architecture
- An operating system controls hardware resources and provides an environment for programs to run.
- The kernel is the core of the operating system, managing hardware resources.
- The shell is a special application that interacts with users and other applications.
- System calls provide the interface between applications and the kernel.
- Libraries of common functions are built on top of system calls, and applications can use either.
Logging In
- Logging in to a UNIX system involves entering a login name and password.
- The system looks up the login name in a password file (/etc/passwd).
- The password file has fields including login name, encrypted password, user ID, group ID, home directory, and shell program.
- Contemporary systems store encrypted passwords in a different file.
Shells
- Shells are command-line interpreters that read and execute user input.
- Shells are used interactively at the terminal, or from files (shell scripts).
- Common shells include Bourne shell, Bourne-again shell, C shell, Korn shell, and TENEX C shell.
- The shell to be used is determined by the final field in the user's password file entry.
Files and Directories
- The UNIX file system is a hierarchical arrangement of directories and files.
- Directories are files that contain directory entries (filenames and attributes).
- Filename attributes include file type (regular file, directory), size, owner, permissions, and last modification time.
- File paths use slashes to denote directories.
- Paths can be absolute(start with /) or relative.
- Special filenames, like ".", refer to the current directory, and ".." to the parent directory.
Process and Process ID
- An executing program is a process.
- UNIX systems assign a unique numeric ID (PID) to each process.
getpid()
function returns the process ID.
Time Values
- Calendar time is the number of seconds since the Unix epoch (January 1, 1970).
- Process time (CPU time) measures the time a process uses the CPU.
System Calls and Library Functions
- System calls are the entry points into the kernel for requesting services.
- System calls are typically implemented as C functions in the standard C library.
- Library functions provide services, often simplifying or enhancing system calls.
- The relationship between system calls and library functions is illustrated using
malloc
andtime
functions as examples.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.