mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
new: 内核态fork
This commit is contained in:
@ -3,7 +3,7 @@ CFLAGS += -I .
|
||||
|
||||
kernel_common_subdirs:=libELF math
|
||||
|
||||
all: glib.o printk.o cpu.o bitree.o kfifo.o wait_queue.o mutex.o wait.o
|
||||
all: glib.o printk.o cpu.o bitree.o kfifo.o wait_queue.o mutex.o wait.o unistd.o
|
||||
@list='$(kernel_common_subdirs)'; for subdir in $$list; do \
|
||||
echo "make all in $$subdir";\
|
||||
cd $$subdir;\
|
||||
@ -33,4 +33,7 @@ mutex.o: mutex.c
|
||||
gcc $(CFLAGS) -c mutex.c -o mutex.o
|
||||
|
||||
wait.o: sys/wait.c
|
||||
gcc $(CFLAGS) -c sys/wait.c -o sys/wait.o
|
||||
gcc $(CFLAGS) -c sys/wait.c -o sys/wait.o
|
||||
|
||||
unistd.o: unistd.c
|
||||
gcc $(CFLAGS) -c unistd.c -o unistd.o
|
21
kernel/common/unistd.c
Normal file
21
kernel/common/unistd.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <common/unistd.h>
|
||||
|
||||
/**
|
||||
* @brief fork当前进程
|
||||
*
|
||||
* @return pid_t
|
||||
*/
|
||||
pid_t fork(void)
|
||||
{
|
||||
return (pid_t)enter_syscall_int(SYS_FORK, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief vfork当前进程
|
||||
*
|
||||
* @return pid_t
|
||||
*/
|
||||
pid_t vfork(void)
|
||||
{
|
||||
return (pid_t)enter_syscall_int(SYS_VFORK, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
@ -12,3 +12,17 @@
|
||||
|
||||
#include <syscall/syscall.h>
|
||||
#include <syscall/syscall_num.h>
|
||||
|
||||
/**
|
||||
* @brief fork当前进程
|
||||
*
|
||||
* @return pid_t
|
||||
*/
|
||||
pid_t fork(void);
|
||||
|
||||
/**
|
||||
* @brief vfork当前进程
|
||||
*
|
||||
* @return pid_t
|
||||
*/
|
||||
pid_t vfork(void);
|
Reference in New Issue
Block a user