Ch 2: Fundamental Concepts Flashcards
Groups:
Basic Idea
- Users are organized into groups
- Each group is identified by a line in the:
- System Group File
- /etc/group
- System Group File
Groups:
Information in the
System Group File
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
Users:
Associated Data and Files
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
Location of the
System Password File
/etc/passwd
Kernel Tasks:
Process Scheduling
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
Tasks Performed
by the Kernel (7)
- 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
Accessing
Command Line Arguments
in C Programs
- 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
Processes:
Memory Segments of a Process
- Text
- Data
- Heap
- Stack
Processes:
Memory Segments of a Process:
Text
The instructions of the program
Processes:
Memory Segments of a Process:
Data
The static variables used by the program
Processes:
Memory Segments of a Process:
Heap
An area from which the program can
dynamically allocate additional memory
during runtime (generally through malloc/calloc)
Processes:
Memory Segments of a Process:
Stack
- 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
System Call Function
to create a child process
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()
System Call Function
to Load and Execute
a new Program
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”
Process ID:
pid
ppid
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)
Kernel Tasks:
Provision of a File System
The Kernel provides a file system on disk.
Allows files to be:
- Created
- Retrieved
- Updated
- Deleted
- etc…
Kernel Tasks:
Memory Management:
Advantages of
Virtual Memory Management
- 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
the Kernel:
Overview
- Synonym for the more narrow definition of an operating system
- The control software that manages and allocates computer resources
Kernel Tasks:
Creation of a Process
The Kernel:
- loads a new program into memory
- provides it with resources it needs to run
- CPU
- Memory
- Access to files
Kernel Task:
Termination of a process
- Happens once a process has completed execution
- Kernel ensures that the resources it uses are freed for use by later programs
Kernel Tasks:
Access to Devices
- 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