Ch 2: Fundamental Concepts Flashcards

1
Q

Groups:

Basic Idea

A
  • Users are organized into groups
  • Each group is identified by a line in the:
    • System Group File
      • /etc/group
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Groups:

Information in the

System Group File

A

For each group, the System Group File records:

  • Group Name
  • Group ID (GID)
  • User List
    • Comm separated list
    • login names of users in this group
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Users:

Associated Data and Files

A

For each user, the System Password File (/etc/passwd)

Stores:

  • login name (username) - unique
  • user ID (UID) - unique
  • Group ID
    • First group of which the user is a member.
  • Home Directory:
    • Initial directory where user is placed
  • Login Shell:
    • The shell to use for this user
  • May also include an encrypted password, but usually stored in shadow password file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Location of the

System Password File

A

/etc/passwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Kernel Tasks:

Process Scheduling

A

The Kernel controls which processes are executed on the processors.

  • Unix/Linux have a Preemptive Multitasking OS
  • Preemptive:
    • The rules are determined by the kernel process scheduler, rather than the processes themselves
  • Multitasking:
    • Multiple processes can reside in memory and take turns using the CPU
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Tasks Performed

by the Kernel (7)

A
  • Process Scheduling
  • Memory Management
  • Creation and Termination of processes
  • Provision of a file system
  • Access to devices
  • Networking
  • Handling System Calls
    • Through System Call API
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Accessing

Command Line Arguments

in C Programs

A
  • The command line arguments are made available through the “main” function
  • In the source code, declare the main function:

int main( int argc, char *argv[] )

  • argc is the number of arguments recieved
  • argv is an array of pointers to the argument strings
  • The first arg in argv, argv[0], is the name of the program itself
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Processes:

Memory Segments of a Process

A
  • Text
  • Data
  • Heap
  • Stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Processes:

Memory Segments of a Process:

Text

A

The instructions of the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Processes:

Memory Segments of a Process:

Data

A

The static variables used by the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Processes:

Memory Segments of a Process:

Heap

A

An area from which the program can

dynamically allocate additional memory

during runtime (generally through malloc/calloc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Processes:

Memory Segments of a Process:

Stack

A
  • A piece of memory varying in size
  • Grows and Shrinks as functions are called and return
  • Used to allocate storage for:
    • local variables
    • function call linkage information
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

System Call Function

to create a child process

A

fork()

  • The process that calls fork() is the parent process
  • The new process is called the child process
  • Kernel creates the child by copying the parent
    • Child inherits the parent’s data, stack and heap
    • The child can modify copies of these independently of the parent’s copies
  • Child either executes a different set of functions than parent, or calls a new program with the command execve()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

System Call Function

to Load and Execute

a new Program

A

execve()

  • Used by child process to load a new program(Execute)
  • Destroys existing text, data, stack and heap,
    • Replaced with new memory segments for the new program
  • Several C library functions are layered on execve()
    • begin with “exec”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Process ID:

pid

ppid

A

Each process has a unique identifying integer, called:

Process Identifier (pid)

Each process also has the pid of it’s parent process,

called the

Parent Process Identifier (ppid)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Kernel Tasks:

Provision of a File System

A

The Kernel provides a file system on disk.

Allows files to be:

  • Created
  • Retrieved
  • Updated
  • Deleted
  • etc…
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Kernel Tasks:

Memory Management:

Advantages of

Virtual Memory Management

A
  • Processes are isolated from one another and from the kernel
    • One process cannot read or modify the memory of another process or kernel
  • Only part of a process needs to be kept in memory
    • _​_Lowers memory requirements
    • Allows more processes to be held in RAM
    • Leads to better CPU Utilization, since it is more likely that there is always a procss that can be executed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

the Kernel:

Overview

A
  • Synonym for the more narrow definition of an operating system
  • The control software that manages and allocates computer resources
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Kernel Tasks:

Creation of a Process

A

The Kernel:

  • loads a new program into memory
  • provides it with resources it needs to run
    • CPU
    • Memory
    • Access to files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Kernel Task:

Termination of a process

A
  • Happens once a process has completed execution
  • Kernel ensures that the resources it uses are freed for use by later programs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Kernel Tasks:

Access to Devices

A
  • The Kernel provides programs with an interface for devices
  • The interface standardizes and simplifies access to various input/output devices
  • The Kernel also arbitrates access by multiple processes to each device
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Kernel Tasks:

Networking

A

The Kernel transmits and recieves network messages(packets) on behalf of user processes.

This includes routing of network packets to the target system.

23
Q

Kernel Tasks:

System Call API

A

Processes can request the kernel to perform various tasks.

Accomplished with kernel entry points

known as System Calls

24
Q

Virtual Private Computer

A
  • Generally provided by any Multiuser OS, such as Unix/Linux
  • Each user can log on to the system and operate largely independently of other users
  • Each user has their own disk storage space( home directory)
  • Users can run programs, which each get a share of the CPU and operate in their own Virtual Address Space
  • Each program can independently access devices and transfer data over the network
  • Kernel resolves potential conflicts in accessing hardware resources
  • Allows users and processes to be generally unaware of others
25
Two CPU Modes
Kernel Mode User Mode
26
CPU Modes: Kernel Mode vs User Mode
* Areas of virtual memory can be marked as either _User Space_ or _Kernel Space_ * If in _User Mode_, the CPU can only access memory in _User Space_ * If in _Kernel Mode_, the CPU can access memory in _both_ User Space and Kernel Space * Hardware instructions allow switching from one mode to the other * Certain operations, like "halt" and accessing memory management hardware, can only be performed in Kernel Mode.
27
What is a "Shell" ?
A "Shell" is a special purpose program designed to _read commands_ typed by a user and _execute_ appropriate programs in response to these commands. Also called a "Command Interpreter"
28
Historically Important Shells
Bourne Shell - sh C Shell - csh Korn Shell - ksh Bourne Again Shell - bash
29
What are Shell Scripts?
* Text files which contain shell commands * They are interpreted by the shell to perform more complex operations at once
30
Super User: Overview
* One user who has special priveleges within the system * has User ID 0 * Normally has login name _root_ * Typically bypasses all permission checks in the system * Can access any file in the system, regardless of permissions * Can send signals to any user process in the system * Normally used by the _System Administrator_
31
C I/O: Library and Functions
* stdio * File Access and I/O Functions are layered on top of system calls * Functions: * fopen() * fclose() * scanf() * printf() * fgets() * gputs()
32
Definition: Filter Program
A Filter is a program that: * reads its input from stdin * performs some transformation on that input * writes the transformed data to stdout
33
Examples of Filter Programs (7)
* cat * grep * sed * sort * tr * wc * awk
34
Two Meanings of "Operating System"
* Broad Definition: * Entire package consisting of the central software used to manage a computer's resources, and all the accompanying standard software tools * Narrow Definition: * The central software that manages and allocates system resources * CPU, RAM and devices * Often referred to as the **_"Kernel"_**
35
Unix Directory Structure: Overview
* The kernel maintains a single hierarchical directory structure to organize all files in the system * This is different from OSs similar to Microsoft Windows, where different disk drives have separate hierarchies * The Base of the hierarchy is the **_Root Directory_** * A simple slash: **\**
36
Unix Directory Structure: Important Immediate Subdirectories of "/"
* bin * boot * etc * home * usr
37
Unix Directory Structure: Diagram of important Directories with contents
38
File Types
* Regular or Plain Files * Ordinary data files * devices * pipes * sockets * directories * symbolic links
39
Directory: Overview
* A directory is a special file whose contents take the form of a table of filenames, coupled with references to the corresponding files * These associations are called **_links_** * Directories can contain links to files and to other directories * All Directories contain at least two entries: * Self: . (dot) * Parent Directory: .. (dot dot)
40
Symbolic Links: Overview
* Works similarly to a regular link, where the name is paired to some file pointer * Is a specially marked file containing the name of another file, called the "**target**" * When the name of a symbolic file is used, the actual file pointed to is substituted in. This is called "**dereferencing**", (or "following") * If the symbolic link refers to a file that doesn't exist, it is called a "**Dangling Link**" * Can be a "**Hard Link**" or a "**Soft Link**"
41
Chapter 2: Fundamental Concepts Important Concept Areas
* Core Operating System: The Kernel * The Shell * Users and Groups * Directory Structure and Links * File Input/Output Model * Programs * Processes * Memory Mappings * Static and Shared Libraries More Advanced * Interprocess Communication and Synchronization * Signals * Threads * Process Groups and Shell Job Control * Sessions, Controlling Terminals * Pseudoterminals * Date and Time * Client-Server Architecture * Realtime * The / proc File System
42
Filenames: The Portable Filename Character Set
* A 65-character set including * Upper and lower case letters (52) * Digits (10) * Special Characters: * Period ( . ) * Underscore ( _ ) * Hyphen ( - ) * This is set as a standard by SUSv3 * Advisable to only use this character set in filenames so that they are portable almost anywhere
43
Pathname: Overview
A pathname is a string consisting of: * an optional intitial slash (/) followed by * a series of filenames separated by slashes. * All but the last of these filenames identifies a directory or a symbolic link that refers to a directory * The final component can be any type of file, including a directory
44
Directory Hierarchy: Important Concepts
* File Types * Directories and Links * Symbolic Links * Filenames * Pathnames * Current Working Directory * File Ownership and Permissions
45
File I/O Model: Important Concepts
* Universality of I/O * File Descriptors * stdio Library
46
Programs: Important Concepts
* Two Forms of Programs: * Source Code * Binary Instructions (executables) * Filters * Command Line Arguments
47
Processes: Important Concepts
* Purpose of a Process * Process Memory Layout * Process Creation * Program Execution * Process ID and Parent Process ID * Process Termination * Termination Status * Process User and Group Identifiers (Permissions/Credentials) * Priviliged Processes * **Capabilities** (actual distinction, not "what it can do") * The "**init**" process * Daemon Processes * Environment List * Resource Limits
48
Memory Mappings: Important Concepts
* mmap() system call * File Mapping * Anonymous Mapping * Purpose of memory mappings
49
Libraries: Important Concepts
* Object Libraries * Static Libraries * Shared Libraries * Dynamic Linker
50
Interprocess Communication and Synchronization: Important Concepts
* Purpose of Interprocess Communication * IPC Mechanisms: * signals * pipes * sockets * file locking * message queues * semaphores * shared memory
51
Signals: Important Concepts
* What signals are * Occurences for sending signals * User interrupt * Child process terminated * Timer expired * Attempt to access invalid memory * Kill command * Possible Actions: * Ignore * Be killed * suspended until later signal * Signal Handler * Signal Mask
52
Pathname: Two Types
* **_Absolute Pathname_** * Begins with a slash (/) and specifies the location with respect to the root directory * Ex: /home/mtk/.bashrc * **_Relative Pathname_** * Specifies the location of a file relative to a process' current working directory. * Distinguished by absence of initial slash * Ex: while in the "home" directory: mtk/.bashrc
53
Current Working Directory: Overview
* Each process has a **Current Working Directory** * This is the process' "current location" in the directory hierarchy * A process inherits this from it's parent process * The login shell has the initial working directory set to the location named in the home directory field of the user's password file entry * Shell can change directory with the "cd" command