UNIX System Architecture and Shells
90 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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.

system calls

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 ______.

<p>shell</p> Signup and view all the answers

When logging in to a UNIX system, we enter our login name followed by our ______.

<p>password</p> Signup and view all the answers

The file that stores user login information in UNIX systems is usually /etc/______.

<p>passwd</p> Signup and view all the answers

In the password file entry, the numeric user ID is represented as ______.

<p>205</p> Signup and view all the answers

Contemporary systems have moved the encrypted ______ to a different file.

<p>password</p> Signup and view all the answers

The names in a directory are called ______.

<p>filenames</p> Signup and view all the answers

The two characters that cannot appear in a filename are the slash character (/) and the ______.

<p>null character</p> Signup and view all the answers

A sequence of one or more filenames, separated by slashes, forms a ______.

<p>pathname</p> Signup and view all the answers

A pathname that begins with a slash is called an ______.

<p>absolute pathname</p> Signup and view all the answers

Two special filenames created in every new directory are . (dot) and ______ (dot-dot).

<p>..</p> Signup and view all the answers

The Research UNIX System restricted a filename to ______ characters.

<p>14</p> Signup and view all the answers

For portability, POSIX.1 recommends that filenames consist of letters, numbers, period, dash, and ______.

<p>underscore</p> Signup and view all the answers

A ______ pathname refers to files relative to the current directory.

<p>relative</p> Signup and view all the answers

The function ______ is used to read one line at a time from standard input.

<p>fgets</p> Signup and view all the answers

The ______ character is often typed as Control-D to signal the end of input.

<p>end-of-file</p> Signup and view all the answers

The program uses ______ to create a new process that is a copy of the caller.

<p>fork</p> Signup and view all the answers

In the child process, ______ is called to execute the command read from standard input.

<p>execlp</p> Signup and view all the answers

To ensure that the command is executed correctly, the program replaces the newline character with a ______ byte.

<p>null</p> Signup and view all the answers

The main process waits for the child process to finish using the ______ function.

<p>waitpid</p> Signup and view all the answers

If fgets returns a null pointer, the loop ______ and the process terminates.

<p>stops</p> Signup and view all the answers

To print the prompt, the program uses the ______ function.

<p>printf</p> Signup and view all the answers

The most common standard I/O function is ______.

<p>printf</p> Signup and view all the answers

The program uses the header ______ to include function prototypes for standard I/O functions.

<p>apue.h</p> Signup and view all the answers

The function ______ reads one character at a time from standard input.

<p>getc</p> Signup and view all the answers

The character read by getc is written using the function ______.

<p>putc</p> Signup and view all the answers

After the last byte of input is read, getc returns the constant ______.

<p>EOF</p> Signup and view all the answers

An executing instance of a program is called a ______.

<p>process</p> Signup and view all the answers

Every process has a unique numeric identifier called the ______.

<p>process ID</p> Signup and view all the answers

The standard I/O constants stdin and stdout are defined in the ______ header.

<p>stdio.h</p> Signup and view all the answers

The program created in the example demonstrates the functions ______ and perror.

<p>strerror</p> Signup and view all the answers

When an error occurs, the program assigns the value ______ to errno to indicate 'No such file or directory'.

<p>ENOENT</p> Signup and view all the answers

Using ______ allows us to know which program generated an error message in a pipeline.

<p>argv[0]</p> Signup and view all the answers

In UNIX coding conventions, passing the program name to perror helps pinpoint the ______ that caused the error.

<p>program</p> Signup and view all the answers

Fatal errors have no recovery actions and require printing an error message to the user or a ______.

<p>log file</p> Signup and view all the answers

System calls usually provide a minimal ______, whereas library functions often provide more elaborate functionality.

<p>interface</p> Signup and view all the answers

The process control system calls (fork, exec, and ______) are usually invoked by the user's application code directly.

<p>waitpid</p> Signup and view all the answers

Resource-related nonfatal errors include codes like EAGAIN, ENFILE, and ______.

<p>ENOSPC</p> Signup and view all the answers

The ______ library function is a common example that simplifies the invocation of system calls.

<p>system</p> Signup and view all the answers

Shared resources being in use can lead to the ______ error being treated as nonfatal.

<p>EBUSY</p> Signup and view all the answers

The typical recovery action for a resource-related nonfatal error is to delay and ______ later.

<p>retry</p> Signup and view all the answers

The ______ library function is often used as a programmer-friendly alternative to the sbrk system call.

<p>malloc</p> Signup and view all the answers

In this text, we'll use the term ______ to refer to both system calls and library functions.

<p>function</p> Signup and view all the answers

Each thread in a multithreaded environment requires a shared copy of errno to function correctly.

<p>False (B)</p> Signup and view all the answers

The value of errno can be both set to 0 and checked when a function indicates success.

<p>False (B)</p> Signup and view all the answers

The perror function outputs an error message based on the specified string and the current value of errno.

<p>True (A)</p> Signup and view all the answers

The function strerror(int *errnum) returns an error message string based on the value of a pointer to errnum.

<p>True (A)</p> Signup and view all the answers

In Linux, errno is defined as a simple global integer variable accessible by all threads.

<p>False (B)</p> Signup and view all the answers

The combination of fork followed by exec is called creating a new thread.

<p>False (B)</p> Signup and view all the answers

The waitpid function is used by the parent process to wait for the child process to finish.

<p>True (A)</p> Signup and view all the answers

Control-D is used to signify the start of input in UNIX systems.

<p>False (B)</p> Signup and view all the answers

To allow arguments in the program, input lines must be parsed to separate the arguments by spaces or tabs.

<p>True (A)</p> Signup and view all the answers

The child process uses execlp to execute a new program file.

<p>True (A)</p> Signup and view all the answers

The ls command can be executed with any specified directory using the current program.

<p>False (B)</p> Signup and view all the answers

Control characters in UNIX systems are formed by pressing the normal key combinations without the control key.

<p>False (B)</p> Signup and view all the answers

The termination status of the child process is ignored in the simple program mentioned.

<p>True (A)</p> Signup and view all the answers

A thread ID from one process is meaningful in another process.

<p>False (B)</p> Signup and view all the answers

Each thread in a process executes on its own stack.

<p>True (A)</p> Signup and view all the answers

The identifier errno is set to a positive value when an error occurs.

<p>False (B)</p> Signup and view all the answers

The open function returns -1 if an error occurs.

<p>True (A)</p> Signup and view all the answers

All functions in UNIX system return a pointer to an object to indicate an error.

<p>False (B)</p> Signup and view all the answers

Threads can access shared data without any need for synchronization.

<p>False (B)</p> Signup and view all the answers

The error constant EACCES indicates a permission problem.

<p>True (A)</p> Signup and view all the answers

Error constants in UNIX begin with the character Z.

<p>False (B)</p> Signup and view all the answers

A fatal error allows for recovery actions to be taken.

<p>False (B)</p> Signup and view all the answers

The error code ENOENT signifies 'No such file or directory'.

<p>True (A)</p> Signup and view all the answers

The perror function in C is used to print an error message associated with a specific error code.

<p>True (A)</p> Signup and view all the answers

Nonfatal errors can always be ignored without consequence.

<p>False (B)</p> Signup and view all the answers

Resource-related nonfatal errors can include temporary issues like resource shortage.

<p>True (A)</p> Signup and view all the answers

The statement 'EACCES: Permission denied' indicates a fatal error condition.

<p>True (A)</p> Signup and view all the answers

Using strerror, you can obtain a string message that describes the error corresponding to a specified error number.

<p>True (A)</p> Signup and view all the answers

The errno variable is used to keep track of error codes for all functions in C.

<p>False (B)</p> Signup and view all the answers

Ignoring a signal is recommended for hardware exceptions like dividing by zero.

<p>False (B)</p> Signup and view all the answers

The default action for a divide-by-zero condition is to terminate the process.

<p>True (A)</p> Signup and view all the answers

Catching a signal involves specifying a function to be executed when the signal occurs.

<p>True (A)</p> Signup and view all the answers

The quit key is typically the Control-C key.

<p>False (B)</p> Signup and view all the answers

A process can send a signal to another process only if it is the owner or the superuser.

<p>True (A)</p> Signup and view all the answers

The process terminates when the SIGINT signal is generated if it has not been set to handle it differently.

<p>True (A)</p> Signup and view all the answers

To generate a signal, one can only use keyboard interrupts.

<p>False (B)</p> Signup and view all the answers

The signal function is called to handle the SIGINT signal by printing a message.

<p>True (A)</p> Signup and view all the answers

The user ID assigned to a user can be changed by the user themselves.

<p>False (B)</p> Signup and view all the answers

Every user in a system has a user ID that is guaranteed to be unique.

<p>True (A)</p> Signup and view all the answers

The superuser or root user has limited permissions in the operating system.

<p>False (B)</p> Signup and view all the answers

Group IDs are used to collect users into groups for resource sharing.

<p>True (A)</p> Signup and view all the answers

Client versions of Mac OS X come with the superuser account enabled by default.

<p>False (B)</p> Signup and view all the answers

The group file in a system maps group names to numeric user IDs.

<p>False (B)</p> Signup and view all the answers

Exponential backoff algorithms involve waiting longer periods in each subsequent retry after an error.

<p>True (A)</p> Signup and view all the answers

The user ID of a user who logs in is presented in the system in decimal form.

<p>True (A)</p> Signup and view all the answers

Flashcards

Operating System (OS)

Software controlling hardware resources and enabling programs to run.

Kernel

The core of an operating system, a small but essential software part.

System Calls

Software layer that acts as an interface between programs and the kernel.

Login Name

Unique identifier used to log in to a UNIX/Linux system.

Signup and view all the flashcards

Password File

File containing user login credentials such as username & password.

Signup and view all the flashcards

User ID (UID)

Numerical user identifier in the password file.

Signup and view all the flashcards

Group ID (GID)

Numerical identifier for a user group within a UNIX/Linux system.

Signup and view all the flashcards

Shell

Application providing an interface to run other applications.

Signup and view all the flashcards

Filename

A name given to a file or directory.

Signup and view all the flashcards

Invalid Filename Characters

Slash (/) and null character cannot be used in filenames.

Signup and view all the flashcards

Recommended Filename Characters

Letters, numbers, period, dash, and underscore are good choices.

Signup and view all the flashcards

Special Filenames

."(dot)" and ".."(dot-dot) are automatically created in new directories.

Signup and view all the flashcards

Filename Length Limit

Maximum filename length varies but is extended to 255 characters in modern systems.

Signup and view all the flashcards

Pathname

Sequence of filenames separated by slashes that specify a file's location in a file system.

Signup and view all the flashcards

Absolute Pathname

A pathname that starts with a slash, specifying a file's location from the root of the file system.

Signup and view all the flashcards

Relative Pathname

A pathname that specifies a file's location relative to the current directory.

Signup and view all the flashcards

Standard I/O function

A set of functions for input and output operations in a program

Signup and view all the flashcards

printf

A standard I/O function used for formatted output to the console

Signup and view all the flashcards

apue.h

A header file containing function prototypes for standard I/O functions

Signup and view all the flashcards

getc(stdin)

Standard I/O function that reads one character from standard input

Signup and view all the flashcards

putc(c, stdout)

Standard I/O function that writes a character (c) to standard output

Signup and view all the flashcards

Process

An executing instance of a program

Signup and view all the flashcards

Process ID

A unique numeric identifier for each process

Signup and view all the flashcards

Program

An executable file on disk ready to run

Signup and view all the flashcards

fgets Function

Reads a line from standard input, stopping at end-of-file.

Signup and view all the flashcards

End-of-File (EOF)

A special character that signals the end of input from a stream (like standard input).

Signup and view all the flashcards

strlen Function

Calculates the length of a string, not including the null terminator.

Signup and view all the flashcards

fork Function

Creates a new process by duplicating the current process.

Signup and view all the flashcards

execlp Function

Executes a new program by replacing the current process with that program.

Signup and view all the flashcards

Parent Process

The original process before the fork.

Signup and view all the flashcards

Child Process

The new process created by fork.

Signup and view all the flashcards

Waitpid Function

Waits for the child process to finish and gets its exit status.

Signup and view all the flashcards

System Calls vs. Library Functions

System calls provide a basic interface, while library functions offer more complex functionality.

Signup and view all the flashcards

sbrk System Call

A system call that manages memory allocation in the operating system. A basic function.

Signup and view all the flashcards

malloc Library Function

A library function that enables programmers to manage dynamic memory allocation, usually in a user-friendly way. More complex than system calls.

Signup and view all the flashcards

Process Control System Calls

System calls related to creating, managing, and controlling processes (e.g., fork, exec, waitpid).

Signup and view all the flashcards

Library Routines (system, popen)

Library functions that simplify common tasks involving system calls. This provides a simpler interface for the programmer.

Signup and view all the flashcards

Fatal Error

An error that cannot be recovered from; the program must exit.

Signup and view all the flashcards

Nonfatal Error

An error that can sometimes be addressed; program can continue running in some cases.

Signup and view all the flashcards

Resource-related error

Errors related to system resources. Can be temporary.

Signup and view all the flashcards

perror()

Prints an error message to stderr, using the errno variable.

Signup and view all the flashcards

strerror()

Converts an error code (e.g., EACCES) into a descriptive error message.

Signup and view all the flashcards

argv[0]

The name of the program itself (e.g., a.out) as passed as a command-line argument.

Signup and view all the flashcards

EACCES error

Access denied error. The program doesn't have necessary permission to access a file or resource.

Signup and view all the flashcards

errno

An integer variable that stores the cause of an error.

Signup and view all the flashcards

Fork-Exec Combination

The act of creating a new process by first using the fork() function to duplicate the current process, and then using the exec() function to replace the child process with a new program.

Signup and view all the flashcards

Spawning a Process

The process of creating a new process, often by using the fork-exec combination.

Signup and view all the flashcards

Control Character

A special character that is generated by pressing combinations of keys, primarily used for controlling the behavior of computer systems.

Signup and view all the flashcards

Process ID (PID)

A unique number assigned to each process, used for identification and communication between processes.

Signup and view all the flashcards

Arguments to a Program

Additional information passed to a program when it is launched, influencing its behavior, such as file names or options.

Signup and view all the flashcards

strerror(errnum)

A function that takes an error number (errnum) and returns a human-readable error message string.

Signup and view all the flashcards

Why is errno important?

It provides a standardized way for programs to diagnose errors and communicate with the operating system about what went wrong.

Signup and view all the flashcards

Why is errno thread-safe?

In multithreaded programs, each thread needs its own copy of errno to prevent interference.

Signup and view all the flashcards

Threads

Multiple threads of control within a single process that share the same memory space and resources.

Signup and view all the flashcards

Thread ID

A unique numerical identifier for a thread within a process. It's local to the process, meaning it's not recognized by other processes.

Signup and view all the flashcards

Thread Synchronization

The mechanism to avoid conflicts when multiple threads access shared data in a process, ensuring data consistency.

Signup and view all the flashcards

Error Handling in UNIX

Functions often return a negative value and set the errno variable to indicate an error. The errno value can be used to identify the specific error that occurred.

Signup and view all the flashcards

errno Variable

An integer variable that holds a value indicating the specific type of error that occurred in a UNIX function.

Signup and view all the flashcards

Error Constants

Specific values assigned to errno to represent different types of errors, typically prefixed with 'E' (e.g., EACCES).

Signup and view all the flashcards

strerror() Function

A function that converts an errno value into a human-readable error message, providing a more descriptive explanation.

Signup and view all the flashcards

Signal

An event that informs a process about an occurrence, such as a hardware exception or user input.

Signup and view all the flashcards

Signal Handling

The process of responding to a signal, typically by ignoring it, executing the default action, or providing a custom function (catching the signal).

Signup and view all the flashcards

Default Action

The standard response to a signal, often pre-defined by the operating system.

Signup and view all the flashcards

Catch a Signal

To provide a custom function to handle a specific signal, allowing the process to control how it reacts.

Signup and view all the flashcards

Interrupt Key

A key, commonly DELETE or Control-C, that sends a signal to interrupt the execution of a process.

Signup and view all the flashcards

Quit Key

A key, typically Control-backslash, that sends a signal to terminate the process.

Signup and view all the flashcards

kill Function

A system function that allows processes to send signals to other processes.

Signup and view all the flashcards

SIGINT

The signal generated by pressing the interrupt key.

Signup and view all the flashcards

What is a User ID?

A unique numeric value assigned to a user account that identifies them to the system. It's given by the system administrator when a login name is created.

Signup and view all the flashcards

What is a Group ID?

A numeric value that identifies a group of users. It's assigned by the system administrator and allows groups to share resources like files.

Signup and view all the flashcards

What is the root user?

The user with user ID 0, also known as superuser. They have special privileges, bypassing most file permission checks.

Signup and view all the flashcards

How are groups used?

Groups gather users together for projects or departments, allowing shared access to resources like files.

Signup and view all the flashcards

What is exponential backoff?

In error handling, an algorithm that increases the wait time between retries after each failed attempt, exponentially.

Signup and view all the flashcards

What is a fatal error?

An error that stops the program from running, meaning it can't be recovered from.

Signup and view all the flashcards

What is a nonfatal error?

An error that the program can sometimes recover from and continue running.

Signup and view all the flashcards

What is the purpose of the perror() function?

The perror() function prints a detailed error message to the console, using information stored in the errno variable.

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 and time functions as examples.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Unix Architecture (Chapter 1)

Description

This quiz covers the fundamentals of the UNIX operating system, including its architecture, kernel, and shell interactions. You'll explore how users log into the system and the role of system calls and libraries. Test your understanding of these essential components of UNIX.

More Like This

Operating Systems Overview
5 questions
UNIX Operating System Structure
5 questions

UNIX Operating System Structure

EffortlessDogwood9877 avatar
EffortlessDogwood9877
UNIX System Introduction Quiz
13 questions
Betriebssysteme und Computerarchitektur Quiz
30 questions
Use Quizgecko on...
Browser
Browser