forked from Azure-stars/Starry
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Arceos-monolithic/zlm_1_2
Zlm 第一阶段任务二(王之栋)
- Loading branch information
Showing
8 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <sys/prctl.h> | ||
#include <asm/prctl.h> | ||
#include <stdlib.h> | ||
#include <sys/mman.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
|
||
int main() { | ||
//获取当前 FS 寄存器的值 | ||
unsigned long* current_fs_value = 0; | ||
if (arch_prctl(ARCH_GET_FS, ¤t_fs_value) != 0) { | ||
perror("arch_prctl(ARCH_GET_FS)"); | ||
return 1; | ||
} | ||
printf("Current FS value set: 0x%lx\n", current_fs_value); | ||
|
||
// 设置新的 FS 寄存器的值 | ||
unsigned long new_fs_value = current_fs_value; | ||
if (arch_prctl(ARCH_SET_FS, new_fs_value) != 0) { | ||
perror("arch_prctl(ARCH_SET_FS)"); | ||
return 1; | ||
} | ||
|
||
printf("New FS value set: 0x%lx\n", new_fs_value); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <unistd.h> | ||
#include <sys/syscall.h> | ||
#include <linux/futex.h> | ||
|
||
int main() { | ||
int futex_var = 0; | ||
|
||
// 创建一个 futex,初始值为 0 | ||
int *futex_ptr = &futex_var; | ||
|
||
// 唤醒等待在 futex 上的线程(私有唤醒) | ||
syscall(SYS_futex, futex_ptr, FUTEX_WAKE_PRIVATE, 1, NULL, NULL, 0); | ||
|
||
return 0; | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters