CS140 Project 1: Threads Slides by Kiyoshi Shikuma.

Slides:



Advertisements
Similar presentations
Project: Processes and Resource Management Textbook: pages Lubomir Bic.
Advertisements

CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
Real-Time Library: RTX
1 Overview Assignment 10: hints  Deadlocks & Scheduling Assignment 9: solution  Scheduling.
Pintos: Threads Project Slides by: Vijay Kumar Updated by Godmar Back.
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
Preemptive Minithreads Tom Roeder CS sp. Multi-level Feedback Queues Quantum = 2 Quantum = 4 Quantum = 8 Quantum = 16 Lowest priority Highest priority.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Process Description and Control A process is sometimes called a task, it is a program in execution.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Introduction to Embedded Systems
Memory Management Page replacement algorithms, segmentation Tanenbaum, ch. 3 p Silberschatz, ch. 8, 9 p
Nachos Phase 1 Code -Hints and Comments
CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.
Chapter 3 Advanced Operating System
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.
Scheduling Strategies Operating Systems Spring 2004 Class #10.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Kernel Locking Techniques by Robert Love presented by Scott Price.
Lecture 8 Page 1 CS 111 Online Other Important Synchronization Primitives Semaphores Mutexes Monitors.
CPS110: Implementing threads Landon Cox. Recap and looking ahead Hardware OS Applications Where we’ve been Where we’re going.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
Pintos: Threads Project
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
CS 3204 Operating Systems Godmar Back Lecture 7. 12/12/2015CS 3204 Fall Announcements Project 1 due on Sep 29, 11:59pm Reading: –Read carefully.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
1 Lecture 6 “Nachos” n nachos overview n directory structure n nachos emulated machine n nachos OS n nachos scheduler n nachos threads.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Tutorial 3: Homework 2 and Project 2
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
CPS110: Implementing threads on a uni-processor Landon Cox January 29, 2008.
CS140 Project Session Notes #1: Threads Haobo Xu, TA Fall Based on Ben Sapp’s slides Download these slides from
Tutorial 2: Homework 1 and Project 1
Multiprogramming. Readings r Chapter 2.1 of the textbook.
ICS143a 2017 Programming Assignment
Topics Covered What is Real Time Operating System (RTOS)
CS703 – Advanced Operating Systems
Background on the need for Synchronization
Threads and Scheduling
Process management Information maintained by OS for process management
Lecture Topics: 11/1 General Operating System Concepts Processes
Lecture 4- Threads, SMP, and Microkernels
Lecture 2 Part 2 Process Synchronization
Real Time Java : Synchronization
February 5, 2004 Adrienne Noble
Thomas E. Anderson, Brian N. Bershad,
CSE 153 Design of Operating Systems Winter 19
CS333 Intro to Operating Systems
Pintos: Threads Project
CSE 153 Design of Operating Systems Winter 2019
EECE.4810/EECE.5730 Operating Systems
Presentation transcript:

CS140 Project 1: Threads Slides by Kiyoshi Shikuma

Overview Quick Review – Threads – Scheduling – Synchronization Project – Pintos – Alarm Clock – Priority Scheduling – Advanced Scheduler

Quick Review: Threads Threads are an execution stream Execution Context: – Current location in program – Values of Variables All maintained on thread’s stack Pintos: Struct thread { name ID stack pointer page directory etc. } This struct is defined in thread.h (a very useful file for this project)

Quick Review: Scheduling ReadyRunning terminated New Waiting admitted scheduled interrupt I/O Event or wait I/O or Event completion Exit

Quick Review: Scheduling cont’d Scheduling Policy – FIFO – Round Robin – Priority Preemption (Remove the “running” thread and schedule a new one) – Timer Interrupt – Device Interrupt (i.e. network, disk, etc)

Quick Review: Thread Scheduling Thread A ___________ ________ Thread B ______ _____ _____ Kernel __ __ __ __ Timer Interrupt Wait on I/O

Quick Background: Synchronization Will be covered in lecture next week Synchronization used to prevent race conditions, avoid concurrency problems One way to avoid synchronization issues is turn off interrupts (only one thing running so no issues), but don’t want to do this Better solution: Use synchronization primitives – Locks – Semaphores – Condition Variables You will probably be modifying synch.h/c

Project: Pintos Simple OS created by Ben Pfaff Could run on x86 hardware but we are using emulators (makes debugging and running easier) – Bochs – Qemu For Threads project you will be (surprise!) working in the threads directory. – Alarm Clock will require modification of timer.c in the devices folder but you shouldn’t need to modify any other files outside threads

Project: Getting Started Follow website instructions to install and set the path variable (suggest adding to.cshrc so you don’t have to set every time) To build run “make” in pintos/src/threads To run tests run “make check” in pintos/src/threads/build – 7/27 tests should pass when you first download and run “pintos” script simplifies usage of simulators: – i.e. “pintos –v -- -q run alarm-single” – Follow instructions to use two terminals to use GDB on pintos – Printf debugging is good too

Project: Alarm Clock Function: void timer_sleep (int64_t ticks) – You will be modifying this function in timer.c – Currently busy waits – Need to instead put thread to sleep and wake it up when enough time has elapsed – Notice that testing suite already passes (most) of the alarm clock tests, so make sure your implementation is correct.

Project: Priority Scheduling Each thread is assigned one of 64 priorities. Current implementation uses a round robin scheduler Change this to instead schedule the highest priority thread that can run (Useful file is thread.h/c)

Project Priority Scheduling Need to consider all cases: – When scheduling the next thread, choose one with highest priority – A thread lowers its priority (should yield if there is a higher-priority thread in the ready list) – A higher priority thread wakes up (such as alarm clock or after waiting on a lock/semaphore) it should preempt the lower priority thread. – Etc.

Project: Priority Donation Problem: Priority Inversion – L acquires a lock – H becomes ready, preempts L and starts running – M becomes ready – H waits for the lock held by L – M starts running M runs, then L, then H After H begins waiting on the lock, L should run (until it releases lock), then H, then M

Project: Priority Donation cont’d Solution: Priority Donation – When H starts waiting on the lock L is holding, it “donates” its priority to L such that L now runs with H’s priority – When L releases the lock, it reverts back to its original priority Nested Donations: H->M->L Multiple Donations: H->L <-M

Project: Advanced Scheduler BSD Scheduler (Read doc linked on site) – Attempts to reduce the average response time of jobs – Calculates statistics during thread execution and sets priorities based on these – Does NOT do priority donation

Design Document Template is on website Start early (don’t wait until you’re done coding to write this) – Thinking through the questions will help you guide your coding Do NOT skimp on this, it is worth just as much as the code

Project: Submission Save design doc as DESIGNDOC in threads directory (no extension) Run “make grade” Copy build/grade to GRADE in threads directory Run “make clean” Run “/usr/class/cs140/bin/submit 1” Submission instructions herehere

Some Advice: Start early Read through the (relevant) docs and code first (it’s very well documented) Think about design before you start coding Meet often as a group to integrate (don’t wait until the last second) Maintain good consistent coding style