Systems software design. Processes, threads and operating system resources

Size: px
Start display at page:

Download "Systems software design. Processes, threads and operating system resources"

Transcription

1 Systems software design Processes, threads and operating system resources

2 Who are we? Krzysztof Kąkol Software Developer Jarosław Świniarski Software Developer Presentation based on materials prepared by Andrzej Ciarkowski, M.Sc., Eng. 2

3 Outline Processes Process properties Multitasking Scheduling Forking Threads Thread properties Threads vs. processes Synchronization Operating system resources Operating systems role in managing resources Unix everything is file philosophy OS services and resources file access APIs memory management

4 What is a process? An instance of computer program being executed A program is a collection of the instructions, a process is actual execution of these instructions There may be multiple process instances for the same program, each executing different code path

5 Process resources Each process owns its resources, like: Image of the executable machine code (may be shared by other program instances, but in rare cases where image is mutable, it is being copied), contained within Identifier (process id, PID) An isolated region of virtual memory Operating system resources (e.g. file handles, timers, synchronization primitives, device handles ) Security attributes (id of process owner, set of permissions) Current state of the processor (execution context) set of registers, mapping of virtual memory to physical addresses Priority needed for scheduling

6 Process memory Each process runs within isolated address space from the others (AKA sandbox) Process address space includes process-specific data structures call stacks of all process threads a heap A stack is a fragment of memory which stores information about the active subroutines, specific to each thread A heap (free store) is a memory region shared between threads used for dynamic memory allocation

7 Multitasking Most modern operating systems appear to run multiple processes (tasks) simultaneously, even when run on single-core (singlethreaded) CPU This is achieved by time-sharing each task (process/thread) receives is given a small period of processor s time, after which it is preempted and a context switch is made to another task With rapid context switches and small enough time slots the tasks seem to the user to be running in parallel

8 Scheduler A part of operating system kernel Algorithm which decides which task should be run next based on task priorities, execution history, I/O state and many other factors The scheduler may be tuned for best Throughput Latency Fairness Deadlines

9 Creating a new process Windows Linux/POSIX See man 3 exec Actually, exec() replaces existing process address space with a new one So you ll need fork() too

10 Forking Unique feature to Unix/POSIX systems is a fork() system call See man 2 fork fork() creates a new process by duplicating the calling process The child process is identical to the parent, including most of the open system resources whose handles are inherited The inheritance of the system resources & memory contents makes for esp. easy IPC between parent and child process, which historically was the reason Unix systems lacked multithreading and used forking for the same purpose

11 How it works?

12 Outline Processes Threads Thread properties Threads vs. processes Synchronization Operating system resources

13 Multithreading Modern operating systems support the notion of multithreading multiple concurrent (simultaneous) execution paths within a single process Threads share the parent process resources (memory, descriptors/handles), but have their own execution stacks (and sometimes security attributes) Since threads share common address space, they can easily communicate with each other using ordinary programming language constructs

14 Thread properties thread of execution running path of code instructions (smallest sequence of instructions that can be managed independently by a scheduler) Each process has at least 1 thread (main thread, program loop) Additional threads may be created on demand to perform some specific tasks (worker threads) Libraries & system may create additional threads which are invisible to the user but make the application multithreaded

15 Threads vs. processes Processes are independent, threads exist as subsets of a process Processes have more state configuration than threads, threads share process state, memory and resources Processes have separate address space, threads share address space Processes interact through systemprovided IPC mechanisms Context switches between threads in same process is faster than between processes

16 Multiple threads vs multiple processes Threads Threads are considered lightweight processes - the amount of information required to process when creating or destroying a thread within existing process is much smaller than it is when creating a new process Their ability to work on the same shared data makes them generally cheaper with regards to system resources than processes Inter-thread communication is easier than inter-process communication Processes Faulty thread can crash entire process, processes are more robust There are techniques which allow to share a region of memory between processes the same (but it s not as natural as with threads) There are techniques which allow creating new processes as cheaply as threads (fork, copy-on-write)

17 Threading what for? Responsiveness perform long, blocking operations in the worker threads so that the application remains responsive to user input and doesn t look frozen Non-blocking I/O may achieve the same without multiple threads but is more error-prone, harder & less natural in use Performance on multicore systems multiple threads allow to achieve the result faster by partitioning the work into parts executed in parallel on separate cores Throughput multithreaded application can better utilize the system by performing work in some threads when other are blocked waiting for I/O to complete

18 Multithreading - dangers Synchronization multiple threads may modify the same data concurrently, leading to unexpected behavior Race condition software depends on the sequence or timing of threads to operate correctly. Without proper synchronization of threads, the timing may be nondeterministic Deadlock improper use of synchronization objects may lead to a state when thread A acquired resource a and waits for thread B to release resource b, while thread B acquired resource b and waits for thread A to release resource a Stability faulty thread crashes the entire process

19 Race conditions Expected Possible These situations cause very difficult to diagnose bugs (Heisenbugs) Solution is to use mutual exclusion (or other synchronization objects, eg. Monitor) or atomic operations

20 Deadlock You need to maintain the same order of resources being acquired in all threads or use safe patterns eg. monitor

21 Synchronization primitives Mutex Semaphore Condition variable Monitor (actually not a primitive) Barrier Read/Write Lock Event (Windows)

22 Mutex MUTual EXclusion object Basic tool for creating critical sections Only one thread at a time may acquire ownership of a mutex Other threads trying to acquire ownership will wait (or try waiting) until first thread releases ownership Operations: acquire (lock) release (unlock) try acquire (try lock) returns boolean value whether ownership was actually acquired

23 Mutex

24 Scoped lock idiom (C++) Using standard lock()/unlock() API is unsafe/uncomfortable in presence of exceptions It s best to use additional scoped lock class which will acquire the lock in constructor and release it in destructor, so even when exception is thrown, the lock will be released preventing the deadlock

25 Semaphore A synchronization object which maintains its lock count (and may optionally have maximum lock count) Increase lock count with signal operation (raise the semaphore) Decrease lock count with wait operation; waiting on semaphore with zero lock count will block until semaphore is raised There s no notion of semaphore owner any thread can signal or wait on semaphore Mutex is a special case of semaphore which maximum lock count of 1 and restriction that only the thread which acquired lock (succeeded in wait) may signal it Semaphores are not as easy to understand & use correctly as mutexes, so try to avoid them until you know what you re doing ;)

26 Barrier Barrier (or rendezvous point) is a place in code where threads in a group are blocked and can not proceed until all of them reached the barrier Barrier enforces synchronization of threads useful in high-performance computing & number crunching

27 Read/Write lock Also called shared mutex A special kind of mutex which allows many threads to simultaneously perform read operation but exclusive write access May provide performance gain in a scenario where the write operation occurs rarely but read operations are common Natively supported on POSIX, not on Windows How it works Writing will cause to block all other writers and readers Writer will wait until all readers have finished Special operation: upgrading rwlock from read mode to write mode Lots of readers may lead to starvation of writers!

28 Outline Processes Threads Operating system resources operating systems role in managing resources Unix everything is file philosophy OS services and resources file access APIs memory management

29 Role of the OS in managing system resources OS is the environment for running and controlling user s tasks It takes care of managing computer s resources planning and scheduling CPU time allocation allocating memory to the tasks provides IPC mechanisms controls the hardware and provides interference-free access to concurrent tasks manages filesystems

30 Role of the OS in managing system resources Allocation of resources Creating and deleting resource descriptors Realization of requests for allocation and release of resources Synchronizing access to resources (prevention of interference) Authorization of access to resources (through system privileges) Recovery of released resources Accounting (collection of statistical data on the use of resources)

31 Managed resources processes CPU time synchronization objects and IPC operating memory memory allocation for processes memory protection files create and delete files and directories read and write operations input / output devices storage media

32 Unix philosophy everything is file Almost all Unix system resources are represented by the files existing in the file system This allows to consistently give permissions to users and processes to these resources and manage their access The same set of tools can be used with many types of resources Access to resources can be achieved by opening the file descriptor representing the device in the file system Files representing devices can exist in the physical file system (on a disk) or in a virtual file systems mounted to the actual disk location (eg. /proc)

33 everything is file resources which are represented by files the actual files and directories sockets and streams I/O devices (device drivers): /dev filesystem character devices (unbuffered access) block devices (buffered access) pseudo-device (eg. /dev/null, /dev/random - the random number generator) synchronization objects (semaphores, mutexes,...) shared memory (shmfs) CPU, physical memory, processes, timers,... (procfs filesystem) many system calls are possible to achieve as a read/write of the specific file

34 File access APIs Operating systems provide an abstraction layer, which allows access to the files in various file systems (local, network, virtual, portable, removable...) to take place in the same way The differences in the implementation of the operations of various file systems are operated by the driver in a manner transparent to the user, using a single set of system calls The operating system provides a unified, standardized programming interface (API)

35 Typical file operations Opening and closing files (create file descriptors or handles for the objects in the file system) file descriptor - abstract identifier (number), usually an index into an array of descriptors managed by the OS for a given process Read, write and file position File metadata management (time of last modification, tags, etc) Directory management Defining the principles of sharing open files between processes, blocking File permissions Encryption

36 File API layers operating systems, programming languages and libraries provide a layered model of files access, providing abstraction of hardware, platform, programming language UNIX Windows C++ standard library C++97 iostream library (fstream class) C++97 iostream library (fstream class) C standard library C89 stdio library (FILE pointer) C89 stdio library (FILE pointer) emulated POSIX file API (int file descriptor) Native OS API Unix/POSIX file API (int file descriptor) Win32 file API (HANDLE)

37 Low-level file access APIs POSIX native API: open()/creat() - return the file descriptor, table of descriptors managed by the OS low-level file operations lack of library-level caching - each operation on the descriptor is a separate system call buffering on the OS cache level Windows native API: CreateFile() open()/creat() - implemented in the standard library based on the native API, table of descriptors is managed by the library 1:1 mapping between the emulated POSIX APIs and Win32 system callse more control over the permissions and file locking using Win32 API POSIX API emulation for compatibility with C89 standard library

38 Buffered I/O API layer Standard C89 Library builds buffered I/O layer on top of low-level POSIX API, based on FILE structure buffering to avoid (costly) system call for each basic I/O operation data is read/written in larger blocks reading/writing individual characters does not involve frequent system calls - performance gains FILE structure contains the information (book keeping) on the properties of an open file descriptor It is possible to obtain a file descriptor from a FILE (function fileno()), but the position of the "descriptor" is different than in the FILE* stream

39 Comparing operations - open operation type characteristics open()/creat() int (file descriptor) native POSIX API, unbuffered, low-level I/O CreateFile() HANDLE native Win32 API, unbuffered, low-level I/O fopen(), _wfopen(), freopen() FILE* buffered stream API provided by the C stdio library based on the low-level API fdopen() FILE* create buffered I/O based on open file descriptor

40 Basic I/O operation type characteristics read()/write() int (file descriptor) native POSIX API ReadFile()/WriteFile() HANDLE native API Win32 ReadFileEx()/ WriteFileEx() HANDLE fread(),fwrite() FILE* buffered C stdio API native API Win32 allows for asynchronous I/O (in the background) fflush() FILE* buffered C stdio API commiting file buffers to the disk (synchronization)

41 Character-based I/O operation type characteristics getc() FILE* buffered C stdio API read next char from the stream putc() FILE* buffered C stdio API write single char to the stream ungetc() FILE* buffered C stdio API undo read of last char

42 Creating and deleting directories and files operation type characteristics CreateDirectory()/ CreateDirectoryEx() RemoveDirectory() DeleteFile() mkdir() rmdir() unlink() remove() creates directory at specified path (Win32) deletes existing (empty) directory deletes file creates directory at specified path (POSIX) deletes existing (empty) directory deletes file name from the filesystem, the actual file will be removed after its last open descriptor is closed deletes file or directory calls unlink() for files, rmdir() for directories

43 Memory management process when creating receives from the OS an area of "free memory", which is commonly called the "arena" arena is managed by the process memory allocator, which is implemented by the programming language/standard library process allocator is used to allocate memory for: stacks of threads of the process objects and structures created in the free memory ("on the heap") the size of the arena can be enlarged with the growing needs of the process this is done in a manner transparent to the user process allocator calls the operating system functions for increasing the arena

44 Process memory allocator Interface of the process allocator provided by the C standard library consists of: malloc() - allocate a continuous memory region with a given size from the heap calloc() - allocate contiguous memory for an N-element vector of objects of a given size realloc() - changes the size of the previously allocated memory block, perhaps moving it to another location free() - frees up memory allocated by malloc(), calloc() or realloc() On the basis of the above APIs are created more advanced memory allocation mechanisms - Garbage collectors, C ++ allocator (new / delete)

45 Process allocator behavior Memory allocated by means of an the process allocator remains occupied until you call free() If memory is not released, "leak occurs block of memory is lost until the end of the process Allocation of many small blocks leads to memory fragmentation, which reduces the efficiency of allocator with the course of the program

46 Questions?

47 Krzysiek Jarek

2/14/2012. Using a layered approach, the operating system is divided into N levels or layers. Also view as a stack of services

2/14/2012. Using a layered approach, the operating system is divided into N levels or layers. Also view as a stack of services Rensselaer Polytechnic Institute CSC 432 Operating Systems David Goldschmidt, Ph.D. Using a layered approach, the operating system is divided into N levels or layers Layer 0 is the hardware Layer 1 is

More information

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio Fall 2017 1 Outline Inter-Process Communication (20) Threads

More information

OS Structure. User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions. Definition, examples, how it works?

OS Structure. User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions. Definition, examples, how it works? Midterm Review OS Structure User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions System call Definition, examples, how it works? Other concepts to know Monolithic kernel vs. Micro

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 Process creation in UNIX All processes have a unique process id getpid(),

More information

OS Structure. User mode/ kernel mode. System call. Other concepts to know. Memory protection, privileged instructions

OS Structure. User mode/ kernel mode. System call. Other concepts to know. Memory protection, privileged instructions Midterm Review OS Structure User mode/ kernel mode Memory protection, privileged instructions System call Definition, examples, how it works? Other concepts to know Monolithic kernel vs. Micro kernel 2

More information

POSIX Threads: a first step toward parallel programming. George Bosilca

POSIX Threads: a first step toward parallel programming. George Bosilca POSIX Threads: a first step toward parallel programming George Bosilca bosilca@icl.utk.edu Process vs. Thread A process is a collection of virtual memory space, code, data, and system resources. A thread

More information

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4 Motivation Threads Chapter 4 Most modern applications are multithreaded Threads run within application Multiple tasks with the application can be implemented by separate Update display Fetch data Spell

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 The Process Concept 2 The Process Concept Process a program in execution

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006 Operating Systems Comprehensive Exam Spring 2006 Student ID # 3/16/2006 You must complete all of part I (60%) You must complete two of the three sections in part II (20% each) In Part I, circle or select

More information

Concurrency: Deadlock and Starvation. Chapter 6

Concurrency: Deadlock and Starvation. Chapter 6 Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involve conflicting needs for resources

More information

2 nd Half. Memory management Disk management Network and Security Virtual machine

2 nd Half. Memory management Disk management Network and Security Virtual machine Final Review 1 2 nd Half Memory management Disk management Network and Security Virtual machine 2 Abstraction Virtual Memory (VM) 4GB (32bit) linear address space for each process Reality 1GB of actual

More information

CS 326: Operating Systems. Process Execution. Lecture 5

CS 326: Operating Systems. Process Execution. Lecture 5 CS 326: Operating Systems Process Execution Lecture 5 Today s Schedule Process Creation Threads Limited Direct Execution Basic Scheduling 2/5/18 CS 326: Operating Systems 2 Today s Schedule Process Creation

More information

Architectural Support for OS

Architectural Support for OS Architectural Support for OS Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3052: Introduction to Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu)

More information

Processes and Threads

Processes and Threads COS 318: Operating Systems Processes and Threads Kai Li and Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall13/cos318 Today s Topics u Concurrency

More information

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1 Windows 7 Overview Windows 7 Overview By Al Lake History Design Principles System Components Environmental Subsystems File system Networking Programmer Interface Lake 2 Objectives To explore the principles

More information

Operating Systems: William Stallings. Starvation. Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall

Operating Systems: William Stallings. Starvation. Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 6 Concurrency: Deadlock and Starvation Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Deadlock

More information

Unix API Books. Linux Kernel Books. Assignments and Exams. Grading for CSC 256. Operating Systems 8/31/2018. CSC 256/456 Fall

Unix API Books. Linux Kernel Books. Assignments and Exams. Grading for CSC 256. Operating Systems 8/31/2018. CSC 256/456 Fall Prerequisites CSC 2/456: Operating s CSC 252 or equivalent C/C++ programming experience on Unix systems Instructor: Sandhya Dwarkadas TAs: Zhuojia Shen, Mohsen Mohammadi 8/31/2018 CSC 2/456 1 2 Meaning

More information

CSE 4/521 Introduction to Operating Systems. Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018

CSE 4/521 Introduction to Operating Systems. Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018 CSE 4/521 Introduction to Operating Systems Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018 Overview Objective: To explore the principles upon which

More information

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts. CPSC/ECE 3220 Fall 2017 Exam 1 Name: 1. Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.) Referee / Illusionist / Glue. Circle only one of R, I, or G.

More information

Thread. Disclaimer: some slides are adopted from the book authors slides with permission 1

Thread. Disclaimer: some slides are adopted from the book authors slides with permission 1 Thread Disclaimer: some slides are adopted from the book authors slides with permission 1 IPC Shared memory Recap share a memory region between processes read or write to the shared memory region fast

More information

Operating Systems : Overview

Operating Systems : Overview Operating Systems : Overview Bina Ramamurthy CSE421 8/29/2006 B.Ramamurthy 1 Topics for discussion What will you learn in this course? (goals) What is an Operating System (OS)? Evolution of OS Important

More information

Introduction. CS3026 Operating Systems Lecture 01

Introduction. CS3026 Operating Systems Lecture 01 Introduction CS3026 Operating Systems Lecture 01 One or more CPUs Device controllers (I/O modules) Memory Bus Operating system? Computer System What is an Operating System An Operating System is a program

More information

CS533 Concepts of Operating Systems. Jonathan Walpole

CS533 Concepts of Operating Systems. Jonathan Walpole CS533 Concepts of Operating Systems Jonathan Walpole Introduction to Threads and Concurrency Why is Concurrency Important? Why study threads and concurrent programming in an OS class? What is a thread?

More information

OPERATING SYSTEMS OVERVIEW. Operating Systems 2015 Spring by Euiseong Seo

OPERATING SYSTEMS OVERVIEW. Operating Systems 2015 Spring by Euiseong Seo OPERATING SYSTEMS OVERVIEW Operating Systems 2015 Spring by Euiseong Seo What is an Operating System? A program that acts as an intermediary between a user of a computer and computer hardware Operating

More information

CSE 410: Systems Programming

CSE 410: Systems Programming CSE 410: Systems Programming Concurrency Ethan Blanton Department of Computer Science and Engineering University at Buffalo Logical Control Flows The text defines a logical control flow as: [A] series

More information

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other No efficient solution Involve conflicting

More information

Main Points of the Computer Organization and System Software Module

Main Points of the Computer Organization and System Software Module Main Points of the Computer Organization and System Software Module You can find below the topics we have covered during the COSS module. Reading the relevant parts of the textbooks is essential for a

More information

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System Overview Chapter 1.5 1.9 A program that controls execution of applications The resource manager An interface between applications and hardware The extended machine 1 2 Structure of a Computer System Structure

More information

Recap: Thread. What is it? What does it need (thread private)? What for? How to implement? Independent flow of control. Stack

Recap: Thread. What is it? What does it need (thread private)? What for? How to implement? Independent flow of control. Stack What is it? Recap: Thread Independent flow of control What does it need (thread private)? Stack What for? Lightweight programming construct for concurrent activities How to implement? Kernel thread vs.

More information

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017 ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 The Operating System (OS) Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke)

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013 Operating Systems Comprehensive Exam Spring 2013 Student ID # 3/20/2013 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

More information

POSIX / System Programming

POSIX / System Programming POSIX / System Programming ECE 650 Methods and Tools for Software Eng. Guest lecture 2017 10 06 Carlos Moreno cmoreno@uwaterloo.ca E5-4111 2 Outline During today's lecture, we'll look at: Some of POSIX

More information

Virtual File System. Don Porter CSE 306

Virtual File System. Don Porter CSE 306 Virtual File System Don Porter CSE 306 History Early OSes provided a single file system In general, system was pretty tailored to target hardware In the early 80s, people became interested in supporting

More information

Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019

Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019 Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019 Bringing It Together OS has three hats: What are they? Processes help with one? two? three? of those hats OS protects itself

More information

The Kernel Abstraction. Chapter 2 OSPP Part I

The Kernel Abstraction. Chapter 2 OSPP Part I The Kernel Abstraction Chapter 2 OSPP Part I Kernel The software component that controls the hardware directly, and implements the core privileged OS functions. Modern hardware has features that allow

More information

Processes. Johan Montelius KTH

Processes. Johan Montelius KTH Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other

More information

CS2506 Quick Revision

CS2506 Quick Revision CS2506 Quick Revision OS Structure / Layer Kernel Structure Enter Kernel / Trap Instruction Classification of OS Process Definition Process Context Operations Process Management Child Process Thread Process

More information

The Kernel Abstraction

The Kernel Abstraction The Kernel Abstraction Debugging as Engineering Much of your time in this course will be spent debugging In industry, 50% of software dev is debugging Even more for kernel development How do you reduce

More information

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Computer Systems A Programmer s Perspective 1 (Beta Draft) Computer Systems A Programmer s Perspective 1 (Beta Draft) Randal E. Bryant David R. O Hallaron August 1, 2001 1 Copyright c 2001, R. E. Bryant, D. R. O Hallaron. All rights reserved. 2 Contents Preface

More information

A process. the stack

A process. the stack A process Processes Johan Montelius What is a process?... a computation KTH 2017 a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other processes

More information

CSE 153 Design of Operating Systems Fall 2018

CSE 153 Design of Operating Systems Fall 2018 CSE 153 Design of Operating Systems Fall 2018 Lecture 4: Processes (2) Threads Process Creation: Unix In Unix, processes are created using fork() int fork() fork() Creates and initializes a new PCB Creates

More information

(MCQZ-CS604 Operating Systems)

(MCQZ-CS604 Operating Systems) command to resume the execution of a suspended job in the foreground fg (Page 68) bg jobs kill commands in Linux is used to copy file is cp (Page 30) mv mkdir The process id returned to the child process

More information

Operating Systems Overview. Chapter 2

Operating Systems Overview. Chapter 2 1 Operating Systems Overview 2 Chapter 2 3 An operating System: The interface between hardware and the user From the user s perspective: OS is a program that controls the execution of application programs

More information

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2.

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2. [03] PROCESSES 1. 1 OUTLINE Process Concept Relationship to a Program What is a Process? Process Lifecycle Creation Termination Blocking Process Management Process Control Blocks Context Switching Threads

More information

The microkernel OS Escape

The microkernel OS Escape The microkernel OS Escape Nils Asmussen FOSDEM 14 1 / 25 Outline 1 Introduction 2 Tasks 3 Memory 4 VFS 5 Demo 2 / 25 Outline 1 Introduction 2 Tasks 3 Memory 4 VFS 5 Demo 3 / 25 Motivation Beginning Writing

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

CSE506: Operating Systems CSE 506: Operating Systems

CSE506: Operating Systems CSE 506: Operating Systems CSE 506: Operating Systems What Software Expects of the OS What Software Expects of the OS Shell Memory Address Space for Process System Calls System Services Launching Program Executables Shell Gives

More information

Processes. Dr. Yingwu Zhu

Processes. Dr. Yingwu Zhu Processes Dr. Yingwu Zhu Process Growing Memory Stack expands automatically Data area (heap) can grow via a system call that requests more memory - malloc() in c/c++ Entering the kernel (mode) Hardware

More information

CSC 4320 Test 1 Spring 2017

CSC 4320 Test 1 Spring 2017 CSC 4320 Test 1 Spring 2017 Name 1. What are the three main purposes of an operating system? 2. Which of the following instructions should be privileged? a. Set value of timer. b. Read the clock. c. Clear

More information

Linux Driver and Embedded Developer

Linux Driver and Embedded Developer Linux Driver and Embedded Developer Course Highlights The flagship training program from Veda Solutions, successfully being conducted from the past 10 years A comprehensive expert level course covering

More information

MARUTHI SCHOOL OF BANKING (MSB)

MARUTHI SCHOOL OF BANKING (MSB) MARUTHI SCHOOL OF BANKING (MSB) SO IT - OPERATING SYSTEM(2017) 1. is mainly responsible for allocating the resources as per process requirement? 1.RAM 2.Compiler 3.Operating Systems 4.Software 2.Which

More information

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4 Temporal relations CSE 451: Operating Systems Autumn 2010 Module 7 Synchronization Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions executed

More information

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering) A. Multiple Choice Questions (60 questions) Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering) Unit-I 1. What is operating system? a) collection of programs that manages hardware

More information

Systems software design. Software build configurations; Debugging, profiling & Quality Assurance tools

Systems software design. Software build configurations; Debugging, profiling & Quality Assurance tools Systems software design Software build configurations; Debugging, profiling & Quality Assurance tools Who are we? Krzysztof Kąkol Software Developer Jarosław Świniarski Software Developer Presentation

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Processes Prof. James L. Frankel Harvard University Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Process Model Each process consists of a sequential program

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

LINUX INTERNALS & NETWORKING Weekend Workshop

LINUX INTERNALS & NETWORKING Weekend Workshop Here to take you beyond LINUX INTERNALS & NETWORKING Weekend Workshop Linux Internals & Networking Weekend workshop Objectives: To get you started with writing system programs in Linux Build deeper view

More information

Outline. CS4254 Computer Network Architecture and Programming. Introduction 2/4. Introduction 1/4. Dr. Ayman A. Abdel-Hamid.

Outline. CS4254 Computer Network Architecture and Programming. Introduction 2/4. Introduction 1/4. Dr. Ayman A. Abdel-Hamid. Threads Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 1 CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science Department Virginia Tech Threads Outline Threads (Chapter

More information

CS 475. Process = Address space + one thread of control Concurrent program = multiple threads of control

CS 475. Process = Address space + one thread of control Concurrent program = multiple threads of control Processes & Threads Concurrent Programs Process = Address space + one thread of control Concurrent program = multiple threads of control Multiple single-threaded processes Multi-threaded process 2 1 Concurrent

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

Disciplina Sistemas de Computação

Disciplina Sistemas de Computação Aula 09 Disciplina Sistemas de Computação Operating System Roles (recall) OS as a Traffic Cop: Manages all resources Settles conflicting requests for resources Prevent errors and improper use of the computer

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

Chapter 6 Concurrency: Deadlock and Starvation

Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles Chapter 6 Concurrency: Deadlock and Starvation Seventh Edition By William Stallings Operating Systems: Internals and Design Principles When two trains

More information

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne Chapter 4: Threads Silberschatz, Galvin and Gagne Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Linux Threads 4.2 Silberschatz, Galvin and

More information

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group Operating Systems (2INC0) 20/19 Introduction (01) Dr. Courtesy of Prof. Dr. Johan Lukkien System Architecture and Networking Group Course Overview Introduction to operating systems Processes, threads and

More information

Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018

Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018 Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018 Last Time CPU Scheduling discussed the possible policies the scheduler may use to choose the next process (or thread!)

More information

Multiple Inheritance. Computer object can be viewed as

Multiple Inheritance. Computer object can be viewed as Multiple Inheritance We have seen that a class may be derived from a given parent class. It is sometimes useful to allow a class to be derived from more than one parent, inheriting members of all parents.

More information

for Operating Systems Computer Systems Laboratory Sungkyunkwan University

for Operating Systems Computer Systems Laboratory Sungkyunkwan University Architectural t Support for Operating Systems Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Basic computer system architecture

More information

Real-Time Programming

Real-Time Programming Real-Time Programming Week 7: Real-Time Operating Systems Instructors Tony Montiel & Ken Arnold rtp@hte.com 4/1/2003 Co Montiel 1 Objectives o Introduction to RTOS o Event Driven Systems o Synchronization

More information

Operating Systems. Synchronization

Operating Systems. Synchronization Operating Systems Fall 2014 Synchronization Myungjin Lee myungjin.lee@ed.ac.uk 1 Temporal relations Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions

More information

CS370 Operating Systems Midterm Review

CS370 Operating Systems Midterm Review CS370 Operating Systems Midterm Review Yashwant K Malaiya Fall 2015 Slides based on Text by Silberschatz, Galvin, Gagne 1 1 What is an Operating System? An OS is a program that acts an intermediary between

More information

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year Dr. Rafiq Zakaria Campus Maulana Azad College of Arts, Science & Commerce, Aurangabad Department of Computer Science Academic Year 2015-16 MCQs on Operating System Sem.-II 1.What is operating system? a)

More information

Architectural Support for Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Architectural Support for Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Architectural Support for Operating Systems Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Basic structure of OS Basic computer

More information

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions Chapter 2 Processes and Threads [ ] 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling 85 Interprocess Communication Race Conditions Two processes want to access shared memory at

More information

Threads and Parallelism in Java

Threads and Parallelism in Java Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program

More information

Lecture 9: Midterm Review

Lecture 9: Midterm Review Project 1 Due at Midnight Lecture 9: Midterm Review CSE 120: Principles of Operating Systems Alex C. Snoeren Midterm Everything we ve covered is fair game Readings, lectures, homework, and Nachos Yes,

More information

Lecture 4: Memory Management & The Programming Interface

Lecture 4: Memory Management & The Programming Interface CS 422/522 Design & Implementation of Operating Systems Lecture 4: Memory Management & The Programming Interface Zhong Shao Dept. of Computer Science Yale University Acknowledgement: some slides are taken

More information

Module 1. Introduction:

Module 1. Introduction: Module 1 Introduction: Operating system is the most fundamental of all the system programs. It is a layer of software on top of the hardware which constitutes the system and manages all parts of the system.

More information

VEOS high level design. Revision 2.1 NEC

VEOS high level design. Revision 2.1 NEC high level design Revision 2.1 NEC Table of contents About this document What is Components Process management Memory management System call Signal User mode DMA and communication register Feature list

More information

Universidad Carlos III de Madrid Computer Science and Engineering Department Operating Systems Course

Universidad Carlos III de Madrid Computer Science and Engineering Department Operating Systems Course Exercise 1 (20 points). Autotest. Answer the quiz questions in the following table. Write the correct answer with its corresponding letter. For each 3 wrong answer, one correct answer will be subtracted

More information

Chapter 5: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads

Chapter 5: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads 5.1 Silberschatz, Galvin and Gagne 2003 More About Processes A process encapsulates

More information

Virtual File System. Don Porter CSE 506

Virtual File System. Don Porter CSE 506 Virtual File System Don Porter CSE 506 History ò Early OSes provided a single file system ò In general, system was pretty tailored to target hardware ò In the early 80s, people became interested in supporting

More information

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable What s An OS? Provides environment for executing programs Process abstraction for multitasking/concurrency scheduling Hardware abstraction layer (device drivers) File systems Communication Do we need an

More information

Processes. Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively.

Processes. Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively. Processes Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively. 1. Process Concept 1.1 What is a Process? A process is a program in

More information

CS 5460/6460 Operating Systems

CS 5460/6460 Operating Systems CS 5460/6460 Operating Systems Fall 2009 Instructor: Matthew Flatt Lecturer: Kevin Tew TAs: Bigyan Mukherjee, Amrish Kapoor 1 Join the Mailing List! Reminders Make sure you can log into the CADE machines

More information

Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies

Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies Chapter 2 Processes and Threads Processes The Process Model 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling Multiprogramming of four programs Conceptual

More information

POSIX Threads: a first step toward parallel programming. George Bosilca

POSIX Threads: a first step toward parallel programming. George Bosilca POSIX Threads: a first step toward parallel programming George Bosilca bosilca@icl.utk.edu Process vs. Thread A process is a collection of virtual memory space, code, data, and system resources. A thread

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Slides based on the book Operating System Concepts, 9th Edition, Abraham Silberschatz, Peter B. Galvin and Greg Gagne,

More information

Chapter 2 Processes and Threads

Chapter 2 Processes and Threads MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads The Process Model Figure 2-1. (a) Multiprogramming of four programs. (b) Conceptual model of four independent,

More information

EECS 482 Introduction to Operating Systems

EECS 482 Introduction to Operating Systems EECS 482 Introduction to Operating Systems Winter 2018 Harsha V. Madhyastha Monitors vs. Semaphores Monitors: Custom user-defined conditions Developer must control access to variables Semaphores: Access

More information

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation Why are threads useful? How does one use POSIX pthreads? Michael Swift 1 2 What s in a process? Organizing a Process A process

More information

CSE 451 Midterm 1. Name:

CSE 451 Midterm 1. Name: CSE 451 Midterm 1 Name: 1. [2 points] Imagine that a new CPU were built that contained multiple, complete sets of registers each set contains a PC plus all the other registers available to user programs.

More information

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Objectives To introduce the notion of a

More information

Concurrency, Thread. Dongkun Shin, SKKU

Concurrency, Thread. Dongkun Shin, SKKU Concurrency, Thread 1 Thread Classic view a single point of execution within a program a single PC where instructions are being fetched from and executed), Multi-threaded program Has more than one point

More information

File Systems. CS170 Fall 2018

File Systems. CS170 Fall 2018 File Systems CS170 Fall 2018 Table of Content File interface review File-System Structure File-System Implementation Directory Implementation Allocation Methods of Disk Space Free-Space Management Contiguous

More information

Lecture 2 Process Management

Lecture 2 Process Management Lecture 2 Process Management Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks The terms job and process may be interchangeable

More information