Preemptive user-level threading library in C++ with round-robin scheduling, created by Noam Kimhi and Or Forshmit as part of the course 67808 - Operating Systems at The Hebrew University of Jerusalem (HUJI).
🎓 Final Grade: 98
- 🧾 Table of Contents
- ✨ Features
- ✅ Prerequisites
- 🛠️ Building the Library
- 🧪 Usage
- 🗂️ Project Structure
- 📄 License
- Preemptive Scheduling: Utilizes virtual timers and signal handling to enable context switching between threads.
- Round-Robin Scheduler: Ensures fair CPU time distribution among threads.
- User-Level Threads: Lightweight threads managed entirely in user space without kernel involvement.
- Minimal Dependencies: Built using standard C++ and POSIX libraries.
- 32-bit Intel arch or 64-bit Intel arch
- A C++ compiler supporting C++11 or higher (e.g.,
g++) - GNU Make (recommended!)
- Clone the repository:
git clone https://github.com/OrF8/uthreads.git cd uthreads - Compile the library:
This will create a library called
make
libuthreads.a. - More
maketargets such asmake tar,make cleanavailable!
Include the uthreads.h header in your project and link against the compiled library. Here's a simple example:
#include "uthreads.h"
void thread_function() {
// Thread-specific code
}
int main() {
uthread_init(quantum_usecs); // Initialize the threading library with a quantum
uthread_spawn(thread_function); // Spawn a new thread
// Additional code
return 0;
}Note: Replace quantum_usecs with the desired quantum in microseconds.
uthreads/
├── Thread.cpp # Implementation of the Thread class
├── Thread.h # Declaration of the Thread class
├── uthreads.cpp # Core library implementation
├── uthreads.h # Library interface
├── Makefile # Build configuration
└── LICENSE # MIT License
This project is licensed under the MIT License-see the LICENSE file for details.