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
Q

Two CPU Modes

A

Kernel Mode

User Mode

26
Q

CPU Modes:

Kernel Mode

vs

User Mode

A
  • 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
Q

What is a “Shell” ?

A

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
Q

Historically Important

Shells

A

Bourne Shell - sh

C Shell - csh

Korn Shell - ksh

Bourne Again Shell - bash

29
Q

What are Shell Scripts?

A
  • Text files which contain shell commands
  • They are interpreted by the shell to perform more complex operations at once
30
Q

Super User:

Overview

A
  • 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
Q

C I/O:

Library and Functions

A
  • stdio
    • File Access and I/O Functions are layered on top of system calls
  • Functions:
    • fopen()
    • fclose()
    • scanf()
    • printf()
    • fgets()
    • gputs()
32
Q

Definition:

Filter Program

A

A Filter is a program that:

  • reads its input from stdin
  • performs some transformation on that input
  • writes the transformed data to stdout
33
Q

Examples of

Filter Programs (7)

A
  • cat
  • grep
  • sed
  • sort
  • tr
  • wc
  • awk
34
Q

Two Meanings of

“Operating System”

A
  • 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
Q

Unix Directory Structure:

Overview

A
  • 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
Q

Unix Directory Structure:

Important Immediate Subdirectories of “/”

A
  • bin
  • boot
  • etc
  • home
  • usr
37
Q

Unix Directory Structure:

Diagram of important Directories

with contents

A
38
Q

File Types

A
  • Regular or Plain Files
    • Ordinary data files
  • devices
  • pipes
  • sockets
  • directories
  • symbolic links
39
Q

Directory:

Overview

A
  • 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
Q

Symbolic Links:

Overview

A
  • 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
Q

Chapter 2: Fundamental Concepts

Important Concept Areas

A
  • 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
Q

Filenames:

The Portable Filename Character Set

A
  • 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
Q

Pathname:

Overview

A

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
Q

Directory Hierarchy:

Important Concepts

A
  • File Types
  • Directories and Links
  • Symbolic Links
  • Filenames
  • Pathnames
  • Current Working Directory
  • File Ownership and Permissions
45
Q

File I/O Model:

Important Concepts

A
  • Universality of I/O
  • File Descriptors
  • stdio Library
46
Q

Programs:

Important Concepts

A
  • Two Forms of Programs:
    • Source Code
    • Binary Instructions (executables)
  • Filters
  • Command Line Arguments
47
Q

Processes:

Important Concepts

A
  • 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
Q

Memory Mappings:

Important Concepts

A
  • mmap() system call
  • File Mapping
  • Anonymous Mapping
  • Purpose of memory mappings
49
Q

Libraries:

Important Concepts

A
  • Object Libraries
  • Static Libraries
  • Shared Libraries
    • Dynamic Linker
50
Q

Interprocess Communication and Synchronization:

Important Concepts

A
  • Purpose of Interprocess Communication
  • IPC Mechanisms:
    • signals
    • pipes
    • sockets
    • file locking
    • message queues
    • semaphores
    • shared memory
51
Q

Signals:

Important Concepts

A
  • 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
Q

Pathname:

Two Types

A
  • 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
Q

Current Working Directory:

Overview

A
  • 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