160 likes | 273 Views
Nachos Walk-through -- Threads. Pengyu Zhang 2/1/2012. Logistics. Assignment 1 timeline: Milestone: Question 1 & 2. 2 /4 – Documentation due. 2 /7 – Code due . Milestone: Question 3 & 4. 2 /11 – Documentation due. 2 /14 – Code due . Deadline: All five questions
E N D
Nachos Walk-through-- Threads Pengyu Zhang 2/1/2012
Logistics • Assignment 1 timeline: • Milestone: Question 1 & 2. • 2/4 – Documentation due. • 2/7 – Code due. • Milestone: Question 3 & 4. • 2/11 – Documentation due. • 2/14 – Code due. • Deadline: All five questions • 2/18 – Documentation due. • 2/21 – Code due. • What to turn in • Documentation • Source code • Tar your threads/ directory.
Logistics • TA office hours: • Time: • Location: • Office hour this week • Bring your laptops • Showus • You have Nachos installed and running • You understand threading system of Nachos • How you split the workload. • You have started your project.
Nachos threads • Lifetime of Nachos threading system • Booting up; • Create new threads; • Running threads; • Finishing all threads and halt.
Creating the first thread • Question: How many threads are created when Nachos is booted? What are they?
Create the ready queue Allocate CPU to the new KThread Set currentThread to the new Kthread Set TCB object Change the status to statusRunning. Create an idle thread.
Make another new KThread, with the target set to an infinite yield() loop. Fork the idle thread off from the main thread.
Creating new threads KThreadnewThread = new KThread(myRunnable); ... newThread.fork();
Creating new threads • Question: why is there a call to ready() method in the fork() method?
Running threads • Question: why is the sleep() method static, while the ready() method isn’t?
Running threads • Question: At which place in KThread.java is the CPU scheduler called to decide which KThread should be given to CPU?
Finishing a thread • Question: when does Nachos Kernel get rid of resources allocated for a thread that is completed? (using OS language, such as “when a new thread is forked”)