Skip to content

This project enhances PintOS's thread system by prioritizing synchronization and implementing a non-busy wait version of timer_sleep()

License

Notifications You must be signed in to change notification settings

brunoribeirol/pintOS

Repository files navigation

Status

Repository Size Language Count Commit Activity License

PintOS - Project 1 (Alarm Clock)

👀 Overview

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()

📝 Implementation Details

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.

Function to Implement

  • 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.

📂 Modified Files:

  • timer.c
    • Implemented timer_sleep()
    • Added wake_up_thread(ticks); in timer_interrupt()
  • thread.h
    • Added int64_t wake_up; to the struct thread
    • Declared typedef struct thread Thread;
    • Added void thread_sleep(int64_t ticks);
    • Added void wake_up_thread(int64_t ticks);
  • thread.c
    • Initialized static struct list blocked_list;
    • Initialized list_init(&blocked_list); in void thread_init(void)
    • Implemented void thread_sleep(int64_t ticks);
    • Implemented void wake_up_thread(int64_t ticks);

🛠️ Code Modifications:

  • /*Start*/: Indicates the start of modifications
  • /*End*/: Indicates the end of modifications
  • Original code is commented using //

🛠️ Build Instructions

  1. Navigate to the directory:
cd pintos/src/threads
  1. Execute the command:
make   

⚙️ Running PintOS

Ensure PintOS is compiled before ruuning:

  1. Navigate to the directory:
cd build
  1. Execute the command:
pintos
  1. Execute the command:
pintos -v -k -T 60 --qemu -- -q run alarm-single

🧪 Test Cases

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

About

This project enhances PintOS's thread system by prioritizing synchronization and implementing a non-busy wait version of timer_sleep()

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published