mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 12:16:31 +00:00
signal的处理(kill命令)以及一些其他的改进 (#100)
* 将entry.S中冗余的ret_from_syscall代码删除,改为jmp Restore_all * new: 增加判断pt_regs是否来自用户态的函数 * new: rust的cli和sti封装 * 将原有的判断pt_regs是否来自用户态的代码,统一改为调用user_mode函数 * ffz函数:获取u64中的第一个值为0的bit * spinlock增加 spinlock irq spin_unlock_irq * 临时解决显示刷新线程迟迟不运行的问题 * 更改ffi_convert的生命周期标签 * new: 测试signal用的app * 解决由于编译器优化导致local_irq_restore无法获取到正确的rflags的值的问题 * new: exec命令增加"&"后台运行选项 * procfs->status增加显示preempt和虚拟运行时间 * 更改引用计数的FFIBind2Rust trait中的生命周期标签 * new: signal处理(kill) * 更正在review中发现的一些细节问题
This commit is contained in:
7
user/apps/test_signal/Makefile
Normal file
7
user/apps/test_signal/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
all: main.o
|
||||
|
||||
ld -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/test_signal $(shell find . -name "*.o") $(shell find $(sys_libs_dir) -name "*.o") -T link.lds
|
||||
|
||||
objcopy -I elf64-x86-64 -R ".eh_frame" -R ".comment" -O elf64-x86-64 $(tmp_output_dir)/test_signal $(output_dir)/test_signal.elf
|
||||
main.o: main.c
|
||||
$(CC) $(CFLAGS) -c main.c -o main.o
|
50
user/apps/test_signal/link.lds
Normal file
50
user/apps/test_signal/link.lds
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
OUTPUT_FORMAT("elf64-x86-64","elf64-x86-64","elf64-x86-64")
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
. = 0x800000;
|
||||
|
||||
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
|
||||
*(.text)
|
||||
|
||||
_etext = .;
|
||||
}
|
||||
. = ALIGN(8);
|
||||
|
||||
.data :
|
||||
{
|
||||
_data = .;
|
||||
*(.data)
|
||||
|
||||
_edata = .;
|
||||
}
|
||||
|
||||
|
||||
rodata_start_pa = .;
|
||||
.rodata :
|
||||
{
|
||||
_rodata = .;
|
||||
*(.rodata)
|
||||
_erodata = .;
|
||||
}
|
||||
|
||||
|
||||
.bss :
|
||||
{
|
||||
_bss = .;
|
||||
*(.bss)
|
||||
_ebss = .;
|
||||
}
|
||||
|
||||
_end = .;
|
||||
|
||||
|
||||
}
|
38
user/apps/test_signal/main.c
Normal file
38
user/apps/test_signal/main.c
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @author longjin (longjin@RinGoTek.cn)
|
||||
* @brief 测试signal用的程序
|
||||
* @version 0.1
|
||||
* @date 2022-12-06
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 测试signal的kill命令的方法:
|
||||
* 1.在DragonOS的控制台输入 exec bin/test_signal.elf &
|
||||
* 请注意,一定要输入末尾的 '&',否则进程不会后台运行
|
||||
* 2.然后kill对应的进程的pid (上一条命令执行后,将会输出这样一行:"[1] 生成的pid")
|
||||
*
|
||||
*/
|
||||
|
||||
#include <libc/math.h>
|
||||
#include <libc/stdio.h>
|
||||
#include <libc/stdlib.h>
|
||||
#include <libc/time.h>
|
||||
#include <libc/unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Test signal running...\n");
|
||||
clock_t last = clock();
|
||||
while (1)
|
||||
{
|
||||
if ((clock()-last)/CLOCKS_PER_SEC >= 1){
|
||||
// printf("Test signal running\n");
|
||||
last = clock();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user