1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Assistant Professor, University of Maryland Baltimore County.

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Advertisements

1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Assistant Professor, University of Maryland Baltimore County.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Processes CSCI 444/544 Operating Systems Fall 2008.
1/27/2010CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying an earlier version.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
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.
CMPT 300: Operating Systems I Ch 3: Processes Dr. Mohamed Hefeeda
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
CSSE Operating Systems
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Process Concept An operating system executes a variety of programs
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operation on Processes.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
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.
Implementing Processes and Process Management Brian Bershad.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process Concept Process – a program.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Assistant Professor, University of Maryland Baltimore County.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 3: Processes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Processes. Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
Computer Studies (AL) Operating System Process Management - Process.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Processes and threads.
Chapter 3: Processes.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Chapter 3: Processes Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Chapter 3: Processes.
Chapter 3: Processes.
Lecture 2: Processes Part 1
Process & its States Lecture 5.
Chapter 3: Processes.
Operating System Concepts
Processes Hank Levy 1.
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix and Windows
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Processes Hank Levy 1.
Chapter 3: Processes Process Concept Process Scheduling
Chapter 3: Process Concept
Presentation transcript:

1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Assistant Professor, University of Maryland Baltimore County

2 Announcements Project 0 and Homework 1 are due this week Readings from Silberchatz [2 nd chapter] Section 2.3

3 Lets write a system call in the kernel (sys_strcpy) int strcpy(char *src, char *dest, int len) asmlinkage long sys_strcpy(char *src, char *dest, int len) compiler directive params will be read from stack can return values of size of at most long? Why?

4 Issues to think about when writing system calls Moving data between the kernel and user process Concerns: security and protection Synchronization and concurrency (will revisit) Several (so called) kernel threads might be accessing the same data structure that you want to read/write Simple solution (disable interrupts “cli”) Usually not a good idea Big problem in preemptive CPU (which is almost every CPU) and multi-processor systems CONFIG_SMP or CONFIG_PREEMPT

5 Useful kernel API functions for bidirectional data movement access_ok (type, addr, size): type (VERIFY_READ, VERIFY_WRITE) get_user(x, ptr) --- read a char or int from user-space put_user(x, ptr) --- write variable from kernel to user space copy_to_user(to, from, n) --- copy data from kernel to userspace copy_from_user(to, from, n) – copy data to kernel from userspace strnlen_user(src, n) – checks that the length of a buffer is n strcpy_from_user(dest, src, n) ---copies from kernel to user space Acknowledgement:

6 Linux Bootup process

7 Intel Motherboard Acknowledgement:

8 Memory Organization during CPU bootup Acknowledgement: BIOS load up Real mode

9 Bootup Process Acknowledgement: BIST (Built in Self Test) CPU loads BIOS code BIOS reads MBR and loads Bootloader Starts the kernel One disk page (512 bytes)

10 Reading the first disk sector Acknowledgement: Boot loader Stage 1 (loads Stage 2) Boot loader Stage 2 (presents users with OS options) Boot loader Stage 3 (loads the OS)

11 Bootup Process Acknowledgement: BIST (Built in Self Test) CPU loads BIOS code BIOS reads MBR and loads Bootloader Starts the kernel One disk page (512 bytes) Bootloader (stage0, stage1, stage2)

12 Lets take a look at some code (Coreboot, GRUB, Kernel)

13 Processes

14 Process Tree generation system process tree

15 But what is a process? n An operating system executes a variety of programs: l Batch system – jobs l Time-shared systems – user programs or tasks n Process – a program in execution; process execution must progress in sequential fashion n A process includes: l program counter l stack l data section

16 Process Memory looks like. virtual Address space why virtual?

17 How do we create new processes in userland (fork) Lets see a demo

18 What is really happening here

19 What does the memory structure look like before fork() Virtual addresses Physical addresses unallocated

20 What does it look like after forking? Parent process Physical addresses Child process

21 Fork() Copy-on-write policy Parent process Physical addresses Child process write to a page

22 communication child/parent process (Unnamed pipes) Pipe(fid); // where int fid[2] fid[0] is the read from the pipe and fid[1] is write to the pipe dup2(oldfid, newfid) //creates an alias to oldfid //very handy when you do not want to use file descriptors and use standard ones

23 Kernel data structure for processes (PCB) Information associated with each process n Process state n Program counter n CPU registers n CPU scheduling information n Memory-management information n Accounting information n I/O status information

24 Kernel data structure for processes (PCB) Represented by the C structure task_struct pid t pid; /* process identifier */ long state; /* state of the process */ unsigned int time slice /* scheduling information */ struct task struct *parent; /* this process’s parent */ struct list head children; /* this process’s children */ struct files struct *files; /* list of open files */ struct mm struct *mm; /* address space of this pro */

25 Process States n As a process executes, it changes state l new: The process is being created l running: Instructions are being executed l waiting: The process is waiting for some event to occur l ready: The process is waiting to be assigned to a processor l terminated: The process has finished execution

26 Process Context Switch n When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch. n Context of a process represented in the PCB n Context-switch time is overhead; the system does no useful work while switching l The more complex the OS and the PCB -> longer the context switch n Time dependent on hardware support l Some hardware provides multiple sets of registers per CPU -> multiple contexts loaded at once

27 Process Context Switch

28 Process Scheduling

29 Process Queues

30 Lets take a kernel dive to study the process data structure and fork() system call

31 Next class Process management Inter-process communication (Named pipes, shared memory (shmget, mmap), message passing) Intro to threads

32 An in-class discussion (a bit-hack)