keos_project5/
process.rs

1//! The process model for project5.
2//!
3//! This file defines the process model of the project5.
4
5use keos_project1::file_struct::FileStruct;
6use keos_project2::mm_struct::MmStruct;
7use keos_project3::lazy_pager::LazyPager;
8
9/// A thread state of project 5, which contains file and memory state.
10#[repr(transparent)]
11#[derive(Default)]
12pub struct Thread(pub keos_project4::Thread);
13
14impl core::ops::Deref for Thread {
15    type Target = keos_project4::Thread;
16    fn deref(&self) -> &Self::Target {
17        &self.0
18    }
19}
20
21impl core::ops::DerefMut for Thread {
22    fn deref_mut(&mut self) -> &mut Self::Target {
23        &mut self.0
24    }
25}
26
27impl Thread {
28    pub fn from_mm_struct(mm_struct: MmStruct<LazyPager>, tid: u64) -> Self {
29        Self(keos_project4::Thread::from_mm_struct(mm_struct, tid))
30    }
31
32    pub fn from_fs_mm_struct(
33        file_struct: FileStruct,
34        mm_struct: MmStruct<LazyPager>,
35        tid: u64,
36    ) -> Self {
37        Self(keos_project4::Thread::from_file_mm_struct(
38            file_struct,
39            mm_struct,
40            tid,
41        ))
42    }
43}