130 likes | 286 Views
Nachos Walk-through -- Threads. Tingxin Yan 2/9/2010. Logistics. Assignment 1 timeline: Milestone: First two questions. 2/15 – Documentation due. 2/18 – Code due. Deadline: All four questions 2/22 – Documentation due. 2/25 – Code due . What to turn in Documentation Source code
E N D
Nachos Walk-through-- Threads Tingxin Yan 2/9/2010
Logistics • Assignment 1 timeline: • Milestone: First two questions. • 2/15 – Documentation due. • 2/18 – Code due. • Deadline: All four questions • 2/22 – Documentation due. • 2/25 – Code due. • What to turn in • Documentation • Source code • Tar your threads/ directory.
Logistics • TA office hours: • Time: Friday 4-6 pm • Location: EdLab (LGRC 223-225) • Office hour this week • Bring your laptops • Show me • 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? • 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”)