This project extends the functionality of the thread system in PintOS, with a focus on synchronization and implementing a non-busy wait version of timer_sleep()
The goal of this project is to reimplement the timer_sleep()
function in devices/timer.c
to avoid busy waiting. This function suspends the calling thread until a specified number of timer ticks have elapsed.
void timer_sleep (int64_t ticks);
- Suspends the calling thread until at least
ticks
timer ticks have elapsed. - Threads do not need to wake up exactly after
ticks
ticks unless the system is idle.
- Suspends the calling thread until at least
timer.c
- Implemented
timer_sleep()
- Added
wake_up_thread(ticks);
intimer_interrupt()
- Implemented
thread.h
- Added
int64_t wake_up;
to thestruct thread
- Declared
typedef struct thread Thread;
- Added
void thread_sleep(int64_t ticks);
- Added
void wake_up_thread(int64_t ticks);
- Added
thread.c
- Initialized
static struct list blocked_list;
- Initialized
list_init(&blocked_list);
invoid thread_init(void)
- Implemented
void thread_sleep(int64_t ticks);
- Implemented
void wake_up_thread(int64_t ticks);
- Initialized
/*Start*/
: Indicates the start of modifications/*End*/
: Indicates the end of modifications- Original code is commented using
//
- Navigate to the directory:
cd pintos/src/threads
- Execute the command:
make
Ensure PintOS is compiled before ruuning:
- Navigate to the directory:
cd build
- Execute the command:
pintos
- Execute the command:
pintos -v -k -T 60 --qemu -- -q run alarm-single
Using the command make check
checks all the tests of PintOS, but your program should only pass these tests:
alarm-single
alarm-multiple
alarm-simultaneous
alarm-zero
alarm-negative