DOC PREVIEW
Princeton COS 318 - Non-Preemptive Scheduling

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

COS 318 Project 2Non-Preemptive SchedulingPrecept 2AgendaQuestions from design review / emailsMiscellaneousGrading criteriaGDB on bochs (CJ Bell)Blocking SemanticsWhen a thread required a LOCKED lock, it gets blocked, not coming back to ready queuewhen a thread releases a lock, it unlocks the first waiting threadlock_release() does not imply do_yield()When a thread is unblocked, it is not executed until all unblocked tasks at the time have yieldedExample Code Thread 1:lock_init(&lock);lock_acquire(&lock);do_yield();lock_release(&lock);do_exit()Thread 4:lock_acquire(&lock);lock_release(&lock);do_exit();Thread 2:while(TRUE) { do_yield();}Thread 3:do_yield();lock_acquire(&lock);lock_release(&lock);do_exit();Example Code Thread 1:lock_init(&lock);lock_acquire(&lock);do_yield();lock_release(&lock);do_exit()Thread 4:lock_acquire(&lock);lock_release(&lock);do_exit();Thread 2:while(TRUE) { do_yield();}Thread 3:do_yield();lock_acquire(&lock);lock_release(&lock);do_exit();T1 acquiresT4 blockedExample Code Thread 1:lock_init(&lock);lock_acquire(&lock);do_yield();lock_release(&lock);do_exit()Thread 4:lock_acquire(&lock);lock_release(&lock);do_exit();Thread 2:while(TRUE) { do_yield();}Thread 3:do_yield();lock_acquire(&lock);lock_release(&lock);do_exit();T1 releasesunblocked T4T3 blockedT4 releasesunblocked T3Lock ImplementationSimple lock implementation: LOCKED, UNLOCKEDDo not have to handle deadlockThink what you should do when:two threads are blocked waiting for the same lock? Follow FIFO ruleSome other process tries to acquire the lock before the unblocked process starts runningPCBPCBs are statically allocated in memory for this projectNo recycling of memory space of any kindstack, pcb, locks.....You may add whatever you feel necessarystart address of a programkernel thread or user processContext Switchingkernel_entry()Used to switch between user process and the kernel for system callssaves and restores user registersscheduler_entry()used to switch between kernel threads and user processes that are in kernelsaves and restores system registersyield() system call (in syslib)goes through kernel_entry() to switch to kernel modegoes through scheduler_entry() to switch to another process/threadExampleProcess P -> Thread Tyield() system call -> kernel_entrysave registers, load kernel stack (working on kernel stack now)do_yield()load user stack, restore user registersdo_yield()enqueue P to ready queuescheduler_entry()save P’s kernel registersscheduler()load T’s kernel registersretFirst time to switch to a taskThere is no return address on stackHow do you find where to return to?ask scheduler to jump to the entry point of the program if it is the first time to runwhat else?Inline AssemblyGeneral format:volatile : _ _asm_ _ volatileflags: refer to the resource page provided on project website_ _asm_ _ (“instruction”“instruction”....“instruction”:”=flags”:”=flags”:”=flags”) ;Grading CriteriaTotal: 10 points + 1 extra credit pointKernel threads and scheduling: 3 pointsProcesses and system calls: 3 pointsMutual exclusion: 2 pointsTiming a context switch: 1 pointCoding style, comments, and README: 1 pointIf your program runs on bochs, but does not run on fishbowl, 1 point penalty at mostGDB for bochsThanks,


View Full Document

Princeton COS 318 - Non-Preemptive Scheduling

Documents in this Course
Overview

Overview

25 pages

Deadlocks

Deadlocks

25 pages

lectute 2

lectute 2

28 pages

Lecturel

Lecturel

24 pages

Real mode

Real mode

49 pages

Lecture 2

Lecture 2

54 pages

lecture 5

lecture 5

27 pages

Load more
Download Non-Preemptive Scheduling
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Non-Preemptive Scheduling and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Non-Preemptive Scheduling 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?