Nachos Project Part 1 1 Goal Understand Nachos
- Slides: 12
Nachos Project: Part 1 1
Goal • Understand Nachos code and organization • Finish the threading mechanism in Nachos • Implement a priority scheduler • Solve a simple concurrency problem using your implementation 2
Part 1 a • • Implement KThread. join Implement condition variables directly using interrupts Complete the Alarm Class Implement synchronous speak() and listen() that transfer 1 word between each other • Basically a zero-length bounded buffer 3
How is Nachos Organized • Important Folders • • • ag: The auto-grader code (DO NOT CHANGE) machine: Emulation (DO NOT CHANGE) network: Kernel Network infrastructure security: Security concerns (DO NOT CHANGE) threads: Threading library userprog: Executes user programs 4
How to run? >cd proj 1 >make javac -classpath. -d. -sourcepath. . /. . -g. . /threads/Threaded. Kernel. javac -classpath. -d. -sourcepath. . /. . -g. . /threads/Boat. java>nachos 5. 0 j initializing. . . config interrupt timer user-check grader*** thread 0 looped 0 times*** thread 1 looped 0 times*** thread 0 looped 1 times*** thread 1 looped 1 times*** thread 0 looped 2 times*** thread 1 looped 2 times*** thread 0 looped 3 times*** thread 1 looped 3 times*** thread 0 looped 4 times*** thread 1 looped 4 times. Machine halting!Ticks: total 2130, kernel 2130, user 0 Disk I/O: reads 0, writes 0 Console I/O: reads 0, writes 0 Paging: page faults 0, TLB misses 0 Network I/O: received 0, sent 0> 5
Debug statements >nachos -d t nachos 5. 0 j initializing. . . config interrupt timer user-check grader. Running thread: main (#0)Forking thread: idle (#1) Runnable: nachos. threads. KThread$2@125127 Ready thread: idle (#1)Enter KThread. self. Test. Forking thread: forked thread (#2) Runnable: nachos. threads. KThread$Ping. Test@fec 107 Ready thread: forked thread (#2)*** thread 0 looped 0 times. Yielding thread: main (#0)Ready thread: main (#0)Switching from: main (#0) to: forked thread (#2)Beginning thread: forked thread (#2)Running thread: forked thread (#2)*** thread 1 looped 0 times. Yielding thread: forked thread (#2)Ready thread: forked thread (#2)Switching from: forked thread (#2) to: main (#0)Running thread: main (#0)*** thread 0 looped 1 times. Yielding thread: main (#0)Ready thread: main (#0)Switching from: main (#0) to: forked thread (#2)Running thread: forked thread (#2). . . 6
Tracing Execution • Begins with machine/Machine. java • Calls the specified Autograder • Autograder starts the Kernel in run(); • kernel. self. Test(); • kernel. run(); • kernel. terminate(); • Kernel runs self. Test() on KThread, Semaphore, and Synch. List • A good place to add more tests 7
KThread Class • • • Manages threading, including creating TCBs and initializing queues Each thread takes in a java Runnable object fork: starts threaded execution finish: End the current thread and schedule it to be destroyed yield: Put the current thread on the ready queue and give CPU to any other thread sleep: Relinquish the CPU until thread is destroyed or woken up ready: Move thread to ready queue join: Wait for this thread to finish self. Test: Perform testing on threads 8
Condition 2 Class • Condition 2(Lock condition. Lock) • Associates the variable with a lock • sleep(): releases the lock and puts the thread to sleep • wake(): wake a waiting thread • wake. ALL(): wake all waiting threads 9
Alarm Class • Alarm(): Sets an interrupt handler to timer. Interrupt() • timer. Interrupt(): Wakes up the thread if it has been longer than the specified sleep time • wait. Until(): Currently just busy waiting, but needs to put the thread to sleep and wake up in timer. Interrupt() 10
Communicator Class • Communicator(): Initializes • speak(): sends a word to someone listening • listen(): gets a word from someone speaking 11
Submitting • Change code only in threads folder • Submit the threads folder • Submit a README file describing what you have done, what works, and what doesn’t 12
- To understand recursion you must understand recursion
- Nachos project
- Nachos kthread
- Nachos project
- Nachos operating system
- Understand quran course 2 pdf
- T tess professional goals examples for teachers
- Solar system inner and outer planets
- How to install nachos on linux in workstation room 217
- Nachos priority scheduler
- Nachos operating system
- Nachos
- Nachos virtual memory