Home: www.cse.dmu.ac.uk/~pkang Phones OFF Please Unix Kernel Parminder Singh Kang Home: www.cse.dmu.ac.uk/~pkang Email: pkang@dmu.ac.uk.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Process Description and Control Module 1.0. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Process Description and Control Chapter 3. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
1 UNIX 1 History of UNIX 2 Overview of UNIX 3 Processes in UNIX 4 Memory management in UNIX 5 The UNIX file system 6 Input/output in UNIX.
Structure of Processes
Operating Systems (OS) Threads, SMP, and Microkernel, Unix Kernel
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Introduction to Kernel
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
Embedded Real-time Systems The Linux kernel. The Operating System Kernel Resident in memory, privileged mode System calls offer general purpose services.
CSCE 351: Operating System Kernels
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
Using Two Queues. Using Multiple Queues Suspended Processes Processor is faster than I/O so all processes could be waiting for I/O Processor is faster.
Phones OFF Please Processes Parminder Singh Kang Home:
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
The Structure of Processes (Chap 6 in the book “The Design of the UNIX Operating System”)
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
LINUX System : Lecture 7 Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
4P13 Week 2 & 3 Talking Points 1. Kernel Processes 2.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
UNIX Unit 1- Architecture of Unix - By Pratima.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
1 Structure of Processes Chapter 6 Process State and Transition Data Structure for Process Layout of System Memory THE DESIGN OF THE UNIX OPERATING SYSTEM.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
What is a Process ? A program in execution.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
WORKING OF SCHEDULER IN OS
Introduction to Operating Systems Concepts
Introduction to Kernel
Process Management Process Concept Why only the global variables?
Structure of Processes
Protection of System Resources
CS 3305 System Calls Lecture 7.
KERNEL ARCHITECTURE.
Structure of Processes
Module 2.2 COP4600 – Operating Systems Richard Newman
Process Description and Control
Lecture Topics: 11/1 General Operating System Concepts Processes
Operating Systems Lecture 3.
Introduction to Operating Systems
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
CS510 Operating System Foundations
Process Description and Control in Unix
CSE 153 Design of Operating Systems Winter 2019
Process Description and Control in Unix
Structure of Processes
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Presentation transcript:

Home: www.cse.dmu.ac.uk/~pkang Phones OFF Please Unix Kernel Parminder Singh Kang Home: www.cse.dmu.ac.uk/~pkang Email: pkang@dmu.ac.uk

Kernel: kernel is the central component of operating system. As a basic component of an operating system, kernel can provide the lowest-level abstraction layer for the resources. Applications and processes use these resources through IPC mechanisms and System calls. Kernel Shell Hardware; CPU, I/O, Memory and Storage Devices

2. Unix Kernel The Unix Kernel is monolithic in design. When it was first written it was fairly small - about 16K bytes. It has grown in size as more and more functions have been added. Berkeley 4.2 was about one megabytes long. BSD 4.3 kernel was about 48000 lines of C and 68000 lines of assembler. The Kernel can be split into two sections :- machine dependent and machine independent

User Program Libraries trap User level Kernel level System call Interface File Subsystem Process Control subsystem IPC Scheduler Memory Management Buffer cache Character/block device drivers Hardware control Hardware level Hardware

Machine dependent part main function is hardware control. incorporating low-level I/O, device drivers, interrupt handlers, context switching and some memory management. Machine Independent Part The machine independent is the rest. Processes communicate with the system via system calls; implemented with a trap or software interrupt instruction. Every process has a user part and a system part. The system part is activated when a system call is made. The Kernel has its own stack and registers. The user stack contains arguments, local variables etc - a fairly standard stack frame in fact.  

Each process has unique process ID. Processes are organised into process groups. A process inherits its group from its parent, although it can change its group.   swapper process zero schedules transfers of processes between memory and backing store. init process 1 fires off login processes and shells for each terminal. page daemon process 2 deals with creating free pages in a virtual memory system.

3. Kernel Structure   Key structure for the kernel is the process table; contains an entry for every process. It is of fixed size - an array (Most kernel structures were initially designed to be simple and are fixed size tables. To make it manageable it has pointers to other tables. The process table contains information which must be accessible to the kernel. The user area contains fields relating to the current process which can be swapped to disk.

user area ----------- --------- | ------>| | | P1 | | | | -------- |--------.--| --------- | | |--------|--| --------- | | | P2 | | | | | | | . ------>| .------> | | | . | | | | | | Pn | | | | | ----------- --------- -------- process table per process memory region table

Process table entries:-   Scheduling details process priority, amount of CPU time used, recently used, sleeping etc. Identifiers unique process id, parent's process id, user id. Memory usage how much space process is using and where it is - memory or disk. This will be pointers to processes page tables, size of process page tables, location of user area page tables etc. Signals signals sent to the process but not yet dealt with. Masks showing which signals are being caught, ignored etc. Sync event process is awaiting Resource accounting pointer to usage, pointer to disk usage. Timer management amount of real-time until timer expires.

The user area :- machine registers in user state; system call state - parameters and results; file descriptor table - files process has open; i/o parameters - amount of data to transfer etc; current directory; permission modes for creating files; accounting information - user time, system time; kernel stack.  

4. Variables Global variables - the process table, data buffers etc - hence are NOT re-entrant. I.e. process switches can only take place at certain points. Kernel itself is not preemptable. I.e. kernel processes run to completion, or until they block. For re-entrant it must not have any global variables. Local variables must be located on a stack frame local to that invocation of the procedure. User processes - pre-emptive scheduling. I.e. CPU can be forcibly taken away from process and new process set running. Runs on user stack in user space. Unprivileged. Kernel - hardware independent - runs until completed or blocked. Can block to wait for resources. Runs on kernel stack in kernel mode. Privileged. Kernel - hardware dependent - Never scheduled. Cannot block. Deals with interrupts. Runs on kernel stack, in kernel address space.

5. Interrupts: - High priority Machine errors Clock Disk Network   High priority Machine errors Clock Disk Network Terminals Low priority Software Interrupt Care has to be taken. If an interrupt occurs while top half of kernel running race conditions can arise. E.g. kernel accessing a buffer cache and interrupt occurs with i/o device. Device could modify cache. Some data structures are shared between top and bottom half of kernel. In this case the top half has to disable interrupts when it is running critical code.

6. Sleep And Wakeup   When process is executing in the kernel it may need to wait for some event. To do this it executes the sleep routine. Process state changed to blocked and scheduler selects other process. When the event occurs the interrupt routine executes the wakeup routine. I.e. process state changed from blocked to runnable. Several processes may be waiting for the same event - all are made runnable. Interrupts are disabled while sleep and wakeup are executing. Kernel sets the priority of the sleeping process according to the reason for sleeping.

process A process B process C | : : v : : buffer locked | : sleeps | : v : buffer locked | sleeps | v buffer locked, sleeps - buffer unlocked. A, B, C woken   ready to run ready to run ready to run Runs - locks : buffer : : : : : sleeps for : : some reason : Runs - buffer : locked - sleeps Runs - buffer locked - sleeps

7. Context Switching Can be done :- when process puts itself to sleep. when process exits. when it is about to return from a system call when interrupt occurs in user mode. Kernel makes sure the state of its data structures is consistent before doing switch.