Processes David Ferry, Chris Gill, Brian Kocoloski

Slides:



Advertisements
Similar presentations
Chap 4 Multithreaded Programming. Thread A thread is a basic unit of CPU utilization It comprises a thread ID, a program counter, a register set and a.
Advertisements

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.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
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.
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.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
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.
CSC 660: Advanced Operating Systems
What is a Process ? A program in execution.
Kernel Structure and Infrastructure David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Linux Boot Process on the Raspberry Pi 2 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis,
Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
Chapter 4: Threads.
Processes and threads.
Linux Details: Device Drivers
Final Review David Ferry, Chris Gill
Operating Systems CMPSC 473
CS 6560: Operating Systems Design
How & When The Kernel Runs
Midterm Review Chris Gill CSE 422S - Operating Systems Organization
Midterm Review David Ferry, Chris Gill
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 4: Multithreaded Programming
Processes David Ferry, Chris Gill
Program Execution in Linux
Process Realization In OS
Intro to Processes CSSE 332 Operating Systems
Semester Review Chris Gill CSE 422S - Operating Systems Organization
Linux Virtual Filesystem
Interrupts and Interrupt Handling
System Structure and Process Model
Chapter 4: Threads.
Processes in Unix, Linux, and Windows
System Structure and Process Model
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Kernel Structure and Infrastructure
CSE 451: Operating Systems Winter 2011 Processes
CSE 451: Operating Systems Winter 2010 Module 4 Processes
Lecture Topics: 11/1 General Operating System Concepts Processes
Virtual Memory.
Linux Details: Device Drivers
Top Half / Bottom Half Processing
Jonathan Walpole Computer Science Portland State University
Kernel Synchronization I
Midterm Review Brian Kocoloski
How & When The Kernel Runs
Semester Review Brian Kocoloski
Chapter 3: Processes.
Chapter 4: Threads.
Virtual Memory: Systems CSCI 380: Operating Systems
fork() and exec() David Ferry CSCI 3500 – Operating Systems
Program Execution in Linux
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Kernel Tracing David Ferry, Chris Gill, Brian Kocoloski
Processes in Unix and Windows
CS703 - Advanced Operating Systems
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 2019
Interrupts and Interrupt Handling
User-level Memory Chris Gill, David Ferry, Brian Kocoloski
Virtual Memory and Paging
Shared Memory David Ferry, Chris Gill
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

Processes David Ferry, Chris Gill, Brian Kocoloski CSE 422S - Operating Systems Organization Washington University in St. Louis St. Louis, MO 63143

Resource Virtualization What resources do you use when you write programs? The processor(s) Memory Files Data (global variables, things like hardcoded strings) What do you not have to worry about generally? Existence of other processes State of hardware resources CSE 422S – Operating Systems Organization

Resource Virtualization The operating system virtualizes physical hardware resources into virtual resources in the form of processes Physical Memory Physical Processors CSE 422S – Operating Systems Organization

Resource Virtualization Process 1 Process 2 Processor Virtualization: Two (or more) processes may share the same set of physical CPUs How to share them? CPU scheduling (next week) Memory Virtualization: Translate private memory addresses to physical addresses Virtual memory (in a few weeks) Physical Memory Physical Processors CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Processes in Linux Fundamental process abstraction: Original: Each process behaves as though it has total control over the system Modern: Threads still execute as though they monopolize the system, but the process abstraction also facilitates multi-threading, signals, and inter-process communication More features: Multi-threading Scheduling Shared memory Virtual Memory Sockets Process accounting etc. Signals Process groups Synchronization CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Tasks in Linux A task/process is an execution stack together with data that describes the process state. (also describes threads) Two stacks: Kernel mode User mode Data: thread_info: small, efficient task_struct: large, statically allocated by slab allocator, points to other data structs User side: Kernel side: User Stack thread_info Kernel stack task_struct .bss .data .text CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization One Size Fits All Processes, threads, and kernel threads are all implemented with the same data structures (thread_info and task_struct) and functions. Threads are like user processes but they share their parent’s address space. Kernel threads don’t have a user-side address space (i.e. mm_struct pointer is NULL) and not all data values are used. CSE 422S – Operating Systems Organization

Threads, Processes, and Kernel Threads Address space thread_info Kernel level Kernel stack .bss (static variables) User level .text (executable code) .data (heap) User stack CSE 422S – Operating Systems Organization

Threads, Processes, and Kernel Threads <set stack pointer to kernel address> <set page table to kernel memory> Address space thread_info Kernel level Kernel stack .bss (static variables) User level main() syscall() .text (executable code) .data (heap) User stack CSE 422S – Operating Systems Organization

Threads, Processes, and Kernel Threads // current is a user-level process struct task_struct * task = current; struct mm_struct * mm = current->mm; Address space thread_info Kernel level Kernel stack .bss (static variables) User level .text (executable code) .data (heap) User stack CSE 422S – Operating Systems Organization

Threads, Processes, and Kernel Threads // current is a kernel thread // (recall, look for processes named // “k …” in ‘ps –aux’) struct task_struct * task = current; struct mm_struct * mm = current->mm; Address space thread_info Kernel level Kernel stack User level NULL CSE 422S – Operating Systems Organization

Threads, Processes, and Kernel Threads struct task_struct * task1; struct task_struct * task2; // fetch task_structs for 2 threads of the same process task1->mm; task2->mm Task 2 Task 1 .bss (static variables) .text (executable code) .data (heap) User level stack stack Stacks are specific per-thread CSE 422S – Operating Systems Organization

Creating a New Process: fork() and clone() Duplicate existing process Initialize per-PID data PID, real_parent, statistics If new process: Copies file handles, signal handlers, process address space, etc. Resources shared via page-level lazy copy-on-write* If new thread: Shares pointers to above resources thread_info Kernel stack task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 thread_info Kernel stack task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 *E.g. Every process in the system shares the same “copy” of the C library CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Kernel Source Clearly illustrated in kernel/fork.c:_do_fork() (line 2018) copy_process() (line 2047) get_task_pid() (line 2060) Kernel thread creation kernel_thread() (line 2107) Process creation via copying kernel/fork.c():copy_process() (line 1537) Lines 1740 through 1764 CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Today’s Studio Explore user-space utilities for process discovery and creation Explore kernel-level data structures used for process management struct task_struct More experience with kernel modules CSE 422S – Operating Systems Organization