Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit 0c84473

Browse files
AsakuraMizuMivik
andauthored
feat: basic process and thread (#34)
* feat: process & thread * feat: PARENT_SETTID, CHILD_SETTID and basic CHILD_CLEARTID Co-authored-by: mivik <mivikq@gmail.com> * fix(clone): thread does not set page table * chore: fix clippy warning * chore: adopt review comments --------- Co-authored-by: mivik <mivikq@gmail.com>
1 parent c883b84 commit 0c84473

File tree

23 files changed

+843
-653
lines changed

23 files changed

+843
-653
lines changed

Cargo.lock

Lines changed: 31 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,18 @@ axns = { git = "https://github.com/oscomp/arceos.git", features = [
3838
axsync = { git = "https://github.com/oscomp/arceos.git" }
3939
axtask = { git = "https://github.com/oscomp/arceos.git" }
4040

41+
axprocess = { git = "https://github.com/Starry-OS/axprocess.git" }
42+
4143
axerrno = "0.1"
4244
bitflags = "2.6"
4345
linkme = "0.3"
46+
linux-raw-sys = { version = "0.9.3", default-features = false, features = [
47+
"no_std",
48+
"general",
49+
"net",
50+
"prctl",
51+
"system",
52+
] }
4453
memory_addr = "0.3"
4554

4655
starry-core = { path = "./core" }
@@ -60,12 +69,18 @@ lwext4_rs = ["axfeat/lwext4_rs"]
6069
[dependencies]
6170
axfeat.workspace = true
6271

72+
axfs.workspace = true
6373
axhal.workspace = true
6474
axlog.workspace = true
75+
axsync.workspace = true
6576
axtask.workspace = true
77+
arceos_posix_api.workspace = true
78+
79+
axprocess.workspace = true
6680

6781
axerrno.workspace = true
6882
linkme.workspace = true
83+
linux-raw-sys.workspace = true
6984

7085
starry-core.workspace = true
7186
starry-api.workspace = true

api/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ axsync.workspace = true
1515
axtask.workspace = true
1616
arceos_posix_api.workspace = true
1717

18+
axprocess.workspace = true
19+
1820
axerrno.workspace = true
1921
bitflags.workspace = true
22+
linux-raw-sys.workspace = true
2023
memory_addr.workspace = true
2124

2225
starry-core.workspace = true

api/src/imp/mm/brk.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use crate::syscall_instrument;
66

77
#[apply(syscall_instrument)]
88
pub fn sys_brk(addr: usize) -> LinuxResult<isize> {
9-
let current_task = current();
10-
let mut return_val: isize = current_task.task_ext().get_heap_top() as isize;
11-
let heap_bottom = current_task.task_ext().get_heap_bottom() as usize;
9+
let task = current();
10+
let process_data = task.task_ext().process_data();
11+
let mut return_val: isize = process_data.get_heap_top() as isize;
12+
let heap_bottom = process_data.get_heap_bottom() as usize;
1213
if addr != 0 && addr >= heap_bottom && addr <= heap_bottom + axconfig::plat::USER_HEAP_SIZE {
13-
current_task.task_ext().set_heap_top(addr as u64);
14+
process_data.set_heap_top(addr);
1415
return_val = addr as isize;
1516
}
1617
Ok(return_val)

api/src/imp/mm/mmap.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ pub fn sys_mmap(
7979
let mut addr = unsafe { addr.into_inner() };
8080

8181
let curr = current();
82-
let curr_ext = curr.task_ext();
83-
let mut aspace = curr_ext.aspace.lock();
82+
let process_data = curr.task_ext().process_data();
83+
let mut aspace = process_data.aspace.lock();
8484
let permission_flags = MmapProt::from_bits_truncate(prot);
8585
// TODO: check illegal flags for mmap
8686
// An example is the flags contained none of MAP_PRIVATE, MAP_SHARED, or MAP_SHARED_VALIDATE.
@@ -163,8 +163,8 @@ pub fn sys_munmap(addr: UserPtr<usize>, length: usize) -> LinuxResult<isize> {
163163
let addr = unsafe { addr.into_inner() };
164164

165165
let curr = current();
166-
let curr_ext = curr.task_ext();
167-
let mut aspace = curr_ext.aspace.lock();
166+
let process_data = curr.task_ext().process_data();
167+
let mut aspace = process_data.aspace.lock();
168168
let length = memory_addr::align_up_4k(length);
169169
let start_addr = VirtAddr::from(addr as usize);
170170
aspace.unmap(start_addr, length)?;
@@ -186,8 +186,8 @@ pub fn sys_mprotect(addr: UserPtr<usize>, length: usize, prot: i32) -> LinuxResu
186186
}
187187

188188
let curr = current();
189-
let curr_ext = curr.task_ext();
190-
let mut aspace = curr_ext.aspace.lock();
189+
let process_data = curr.task_ext().process_data();
190+
let mut aspace = process_data.aspace.lock();
191191
let length = memory_addr::align_up_4k(length);
192192
let start_addr = VirtAddr::from(addr as usize);
193193
aspace.protect(start_addr, length, permission_flags.into())?;

0 commit comments

Comments
 (0)