| Crates.io | tg-sync |
| lib.rs | tg-sync |
| version | 0.1.0-preview.1 |
| created_at | 2026-01-22 13:13:19.355271+00 |
| updated_at | 2026-01-22 13:13:19.355271+00 |
| description | Synchronization primitives for rCore tutorial OS, including mutex, semaphore, and condvar. |
| homepage | https://github.com/rcore-os/rCore-Tutorial-in-single-workspace |
| repository | https://github.com/rcore-os/rCore-Tutorial-in-single-workspace |
| max_upload_size | |
| id | 2061516 |
| size | 16,883 |
Synchronization primitives for the rCore tutorial operating system.
This crate provides essential synchronization primitives for kernel development, including mutexes, semaphores, and condition variables suitable for a teaching operating system.
use tg_sync::{Mutex, MutexBlocking, Semaphore, Condvar};
use tg_sync::{UPIntrFreeCell, UPIntrRefMut};
// Use mutex for mutual exclusion
let mutex = MutexBlocking::new();
mutex.lock();
// critical section
mutex.unlock();
// Use semaphore for resource counting
let sem = Semaphore::new(3);
sem.down();
// use resource
sem.up();
// Use condition variable
let condvar = Condvar::new();
condvar.wait();
condvar.signal();
Mutex - Basic spinlock-based mutexMutexBlocking - Mutex with thread blocking supportSemaphore - Counting semaphoreCondvar - Condition variableUPIntrFreeCell - Interrupt-safe cell for uniprocessor systemstg-task-manage - For thread scheduling integrationLicensed under either of MIT license or Apache License, Version 2.0 at your option.