pintos project 1 - usc bitsbits.usc.edu/cs350/assignments/project1.pdf(priority 100) thread 2...

26
Pintos Project 1 Threads September 7, 2016

Upload: lamphuc

Post on 18-Apr-2018

217 views

Category:

Documents


1 download

TRANSCRIPT

Pintos Project 1Threads

September 7, 2016

Overview

What is Pintos?

A 80x86 operating systems framework developed by Ben Pfaff for Stanford

This is a tried and tested project for learning operating systems

Bad news:“… it works on my machine blah blah blah…” doesn’t workanymore

Good news:“You will know your exact programming grade and check what grade you get before you submit”

More about Pintos

You will need to only code in C

Makefiles are (mostly) provided to youWe will let you know if you need to modify a makefile

Each project consists of two parts:ProgrammingDesign Document (provided each project)

How does Pintos work (abridged version)?

Entry point of Pintos is threads/start.S (this is an assembly file)

start.S will initialize operating system resources, and call main() in threads/init.c

main() will parse command line arguments, setup kernel memory, initialize the interrupt system, and call thread_start() in threads/thread.c for the main thread

For the purposes of your project, the main thread are all the test files we will run.

Development Environment

We will be using Xubuntu 15.10 in Virtual boxSetup instructions can be found on Piazza

This VM has the following already installed:gcc, g++, make, git, gdb, bochs, perl, texinfo/texlive, GNU binutils, gedit, Sublime Text 3, nano, vim, Mousepad, and Pintos

Working with Pintos

Each of the four projects has its own main directory:Project 1: src/threadsProject 2: src/userprogProject 3: src/vmProject 4: src/filesys

For each project, type $make in the project’s main directory to compile your project

Eg. Type $make in src/threadsThis will create a new directory build/You can run $make clean to clean your project

Type $make check to run all the tests in the build/ directoryYou can check how many tests you are passing / failing

Nap room (blocked)Operating System(you)Thread 1

Thread 2

Project 1: Overview

Part 1: Alarm

Project 1: Overview

Part 1: Alarm

Nap room (blocked)Operating System(you)Thread 1

Hey I want to take a nap for 10 seconds

Thread 2

Ok sure

Project 1: Overview

Part 1: Alarm

Nap room (blocked)

Thread 1 (10 s)

Operating System(you)

Thread 2

Project 1: Overview

Part 1: Alarm

Nap room (blocked)

Thread 1 (10 s, 5 seconds left)

Operating System(you)

Thread 2

Hey I want to take a nap for 5 seconds

(5 seconds later)

Ok sure

Project 1: Overview

Part 1: Alarm

Nap room (blocked)

Thread 1 (10 s,5 seconds left)

Thread 2 (5 s)

Operating System(you)

(5 seconds later)

Project 1: Overview

Part 1: Alarm

Nap room (blocked)

Thread 1 (10 s,0 seconds left)

Thread 2 (5 s,0 seconds left)

Operating System(you)

(10 seconds later)

Time to wake up Thread 1 and 2

Nap room (blocked)Operating System(you)Thread 1

Thread 2

Project 1: Overview

Part 1: Alarm

Thread 1(priority 10)

Thread 2(priority 50)

Project 1: Overview

Part 2: Priority Donation

Thread 1(priority 10)

Thread 2(priority 50)

Project 1: Overview

Part 2: Priority Donation

I want this lock

Thread 1(priority 10)

Thread 2(priority 50)

Project 1: Overview

Part 2: Priority Donation

I want this lock too ☹

Thread 3(priority 100, blocked)

Thread 1(priority 10)

Thread 2(priority 50)

Project 1: Overview

Part 2: Priority Donation

Thread 3(priority 100, blocked)

Thread 3 needs to run

Thread 1(priority 100)

Thread 2(priority 50)

Project 1: Overview

Part 2: Priority Donation

Thread 3(priority 100, blocked)

Thread 3 needs to runDONATION

Project 1: Overview

Part 3: MultiLevel Feedback Queue Scheduler

Cancelled ☺

Project 1

Project 1 has three parts:Part 1: AlarmPart 2: Priority DonationPart 3: MultiLevel Feedback Queue

There are 18 tests for you to pass

Project 1 is manageable with ~500 lines

Project 1: Setup

1. Git clone pintos-base to your desktop in the VM2. Make a directory in your private repository named proj1

a) If you don’t you may lose marks3. Copy and paste the contents of pintos-base into your proj1

directory a) DO NOT clone pintos-base into your private repositoryb) DO NOT copy the pintos directory in your VM’s home

directory

Project 1: Alarm

By default timer_sleep in devices/timer.c simply busy waits

This is bad because you cannot guarantee the sleeping thread won’t get scheduled back to the processor, wasting resources for non-sleeping threads

You will have to block the thread to sleep instead of busy-waiting

Project 1: Priority Donation

Thread X waiting on another thread (holding the synchronization resource thread X wants) with a lower priority, thread X must donate its priority

Donations must propagate through a waiting chain (B donates to A, when C waits on B, C donates to B, which must propagate to A)

Donation must work with multiple locks

Project 1: Design Document

Copy doc/threads.tmpl into src/threads/ and rename it DESIGNDOC

If you don’t you may lose marksNo extensions for this file name

Complete the design document questions (skip the MLFQS questions)

Make sure to git add, commit, and push the design document

Project 1: Submission

You must submit by 11:59PM on the due date (September 23)

You are allowed a total of 3 late days this semester

Late day form can be found at https://goo.gl/forms/dv2FzYzmkX4C43103