Skip to content

OrF8/uthreads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uthreads

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

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

✅ Prerequisites

  • 32-bit Intel arch or 64-bit Intel arch
  • A C++ compiler supporting C++11 or higher (e.g., g++)
  • GNU Make (recommended!)

🛠️ Building the Library

  1. Clone the repository:
    git clone https://github.com/OrF8/uthreads.git
    cd uthreads
  2. Compile the library:
    make
    This will create a library called libuthreads.a.
  3. More make targets such as make tar, make clean available!

🧪 Usage

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.

📁 Project Structure

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

📄 License

This project is licensed under the MIT License-see the LICENSE file for details.

About

Preemptive user-level threading library in C++ with Round-Robin scheduling

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •