09 - Kernel and processes Flashcards
What is the primary role of an Operating System (OS) in the context of process management?
- The OS plays a central role in process management.
- It isolates applications to prevent them from affecting each other negatively.
- This isolation is fundamental to ensuring system reliability, security, privacy, and fairness.
Define a process and a thread in the context of operating systems.
- A process is an instance of a running program with limited rights.
- A thread is a sequence of executed instructions within a process.
- A process can have potentially many threads.
- The address space of a process defines its accessible memory and other permissions.
What hardware mechanisms support process protection in operating systems?
- Privileged instructions, available only to the kernel.
- Memory access limits to prevent user code from overwriting kernel space.
- Timers to regain control from user programs.
- Safe ways to switch between user and kernel modes.
Explain the concept of dual-mode operation in the context of operating systems.
- Dual-mode operation includes Kernel mode (full hardware privileges) and User mode (limited privileges).
- Memory protection is achieved through different base and bound registers for kernel and user-level processes.
- This approach ensures safe control transfer between modes and protects kernel memory from user programs.
What is the role of system calls in operating systems?
- System calls provide an interface for applications to interact with the operating system.
- They are used for various operations like process control, file management, device management, information maintenance, and communication.
- In Linux, the number of system calls has increased from around 60 in the first Unix version to over 300 in current versions.
Explain the differences between system calls and library functions.
- System calls are provided by the system and are executed (mostly) in the system kernel.
- They are entry points into the kernel and are therefore NOT linked into your program.
- The source code is not portable
- The API is portable
- Library calls include the ANSI C standard library and are therefore portable. These functions are linked into your program.
How does the kernel handle system calls?
- The kernel uses a stub to locate arguments either in registers or on the user stack.
- It translates user addresses to kernel addresses and copies arguments from user memory to kernel memory.
- The kernel protects itself from malicious code and validates arguments to prevent errors.
- After executing the handler, it copies results back into user memory.
Slide 24, chapter 9
What is User Level Process Management in UNIX?
- User Level Process Management allows processes to create other processes without the need for kernel recompilation.
- This capability is utilized by shell command line interpreters.
- It includes functionalities for job control, such as creation, killing, suspending, and resuming processes.
- Additionally, it provides a job coordination system for pipe-lining and sequencing of processes
What happens when a program is compiled in UNIX?
- Compiling a program, like cc -c file1.c, creates a new process.
- The cc program reads the file and produces output.
- The shell waits for the completion of this process.
- The compilation process can be defined in a file, becoming a program
Describe the kernel operations involved in process creation.
- The kernel allocates process data-structures.
- It allocates memory for the process.
- The program is copied from disk to the allocated memory.
- Stacks are allocated: user-level for functions and kernel-level for system-calls/interrupts.
What occurs during process startup in UNIX?
- The kernel copies arguments from user memory (argc/argv).
- It copies the environment settings.
- Control is transferred to user mode using POP and IRET instructions.
- This occurs after manipulation of the kernel stack
What steps are involved in process termination?
- The
exit
system call is invoked, typically inserted by the compiler. - The kernel executes this call, leading to:
- Freeing of stacks.
- Freeing of process memory.
- Freeing of kernel data-structures.
- Notification to the “parent” process of the termination.
What are the different policies for process creation in UNIX?
- Execution mode policies include whether the father and son processes execute in parallel or if the father blocks until the son terminates.
- Memory management policies determine if the son process gets new memory (data and code), new data, a shared copy of the father’s memory, or a non-shared copy.
- Resource sharing policies cover whether the father and son share all, some, or no resources (like open files, IPC objects, etc.).
How does process creation work in Windows?
- The
CreateProcess
function is used to create and initialize the Process Control Block and the address space. - It loads the program into the address space and copies arguments into process memory.
- The function initializes the hardware context and informs the scheduler of the new process.
- Further security configuration, like limiting privileges and changing priority, is necessary.
What are the process creation policies in Windows?
- In Windows, the execution mode policy is that the father and son execute in parallel.
- For memory management, the son gets new memory (data and code).
- Regarding resource sharing, the father and son do not share most of the resources.