Question: Please help me with this question in rust. Implement a reader-writer lock based on mutexes (std::sync: Mutex) and condition variables (std: isyne::Condvar). You will learn

 Please help me with this question in rust. Implement a reader-writer

lock based on mutexes (std::sync: Mutex) and condition variables (std: isyne::Condvar). You

Please help me with this question in rust.

Implement a reader-writer lock based on mutexes (std::sync: Mutex) and condition variables (std: isyne::Condvar). You will learn how to implement writers-preferred vs. readers-preferred policies; schedule threads in FIFO vs. LIFO policies; implement Deref and DerefMut to provide coercion between pointer types; implement Drop to automatically reset the state before leaving a critical section; use Unsafecell to circumvent Rust's static aliasing rules safely at runtime; Public API Your program must provide the following public API. /// Provides a reader-writer lock to protect data of type T pub struct RwLock #1 derive PartialE91 pub enum Preference1 / Readers-preferred Readers must wait when a writer is active Writers must wait when a reader is active or waiting, or a writer is active Reader / Writers-preferred: Readers must wait when a writer is active or waiting Writer must wait when a reader or writer is active Writer In which order to schedule threads pub enum order First in first out Fifo Last in first out Lifo Constructs a new RwLock / data: the shared object to be protcted by this lock pref: which preference / order: in which order to wake up the threads waiting on this lock pub fn new (data: T, pref: Preference, order: Order) >RwLock -> ResultRwLockReadGuardcT>, ()> { Requests a write lock, and waits when necessary When the lock becomes available, /// * if order-order ;:Fito'' wakes up the first thread /// * if order-order: :Lito. wakes up the last thread Always returns ok) pub fn write(&self> Result RwLockwriteGuardcT>, >

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!