git://scm.lunaixsky.com
/
lunaix-os.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
aa8afd3
)
feat: pause(2) support
author
Minep
<zelong56@gmail.com>
Mon, 20 Jun 2022 16:19:11 +0000
(17:19 +0100)
committer
Minep
<zelong56@gmail.com>
Mon, 20 Jun 2022 16:19:11 +0000
(17:19 +0100)
lunaix-os/includes/lunaix/lunistd.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/process.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/status.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/syscall.h
patch
|
blob
|
history
lunaix-os/kernel/asm/x86/syscall.S
patch
|
blob
|
history
lunaix-os/kernel/lxinit.c
patch
|
blob
|
history
lunaix-os/kernel/signal.c
patch
|
blob
|
history
diff --git
a/lunaix-os/includes/lunaix/lunistd.h
b/lunaix-os/includes/lunaix/lunistd.h
index 42c432018dda74d4437ec810ab4717f2b6b3bf86..7a1c3689a7d5c8faad57b60a3c84a7a06e506682 100644
(file)
--- a/
lunaix-os/includes/lunaix/lunistd.h
+++ b/
lunaix-os/includes/lunaix/lunistd.h
@@
-18,4
+18,6
@@
__LXSYSCALL1(void, _exit, int, status)
__LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
__LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
+__LXSYSCALL(int, pause)
+
#endif /* __LUNAIX_UNISTD_H */
#endif /* __LUNAIX_UNISTD_H */
diff --git
a/lunaix-os/includes/lunaix/process.h
b/lunaix-os/includes/lunaix/process.h
index 7a5d5024ef0c2a41c0ad0a2b9ddf62e35e9d9615..2cd4330b041b8f711bafb6bbf13d489aabe9104f 100644
(file)
--- a/
lunaix-os/includes/lunaix/process.h
+++ b/
lunaix-os/includes/lunaix/process.h
@@
-21,6
+21,8
@@
#define PROC_TERMMASK 0x6
#define PROC_TERMMASK 0x6
+#define PROC_FINPAUSE 1
+
struct proc_mm
{
heap_context_t u_heap;
struct proc_mm
{
heap_context_t u_heap;
@@
-64,6
+66,7
@@
struct proc_info
int32_t k_status;
sigset_t sig_pending;
sigset_t sig_mask;
int32_t k_status;
sigset_t sig_pending;
sigset_t sig_mask;
+ int flags;
void* sig_handler[_SIG_NUM];
pid_t pgid;
struct lx_timer* timer;
void* sig_handler[_SIG_NUM];
pid_t pgid;
struct lx_timer* timer;
diff --git
a/lunaix-os/includes/lunaix/status.h
b/lunaix-os/includes/lunaix/status.h
index f3309ab3207f31f04bfda353862989b02f8ececc..aeef93e5c16e6abf9cb44382fd490c44d857440b 100644
(file)
--- a/
lunaix-os/includes/lunaix/status.h
+++ b/
lunaix-os/includes/lunaix/status.h
@@
-9,4
+9,6
@@
#define LXSEGFAULT -(5)
#define LXINVL -(6)
#define LXSEGFAULT -(5)
#define LXINVL -(6)
+#define EINTR -(7)
+
#endif /* __LUNAIX_CODE_H */
#endif /* __LUNAIX_CODE_H */
diff --git
a/lunaix-os/includes/lunaix/syscall.h
b/lunaix-os/includes/lunaix/syscall.h
index 3a6e2eba10285ed8f84726ab543f5d40a52a0b50..f695cf78cf13605463d629a9396816d3fec2f283 100644
(file)
--- a/
lunaix-os/includes/lunaix/syscall.h
+++ b/
lunaix-os/includes/lunaix/syscall.h
@@
-33,11
+33,6
@@
syscall_install();
#define __PARAM_MAP5(t1, p1, ...) t1 p1, __PARAM_MAP4(__VA_ARGS__)
#define __PARAM_MAP6(t1, p1, ...) t1 p1, __PARAM_MAP5(__VA_ARGS__)
#define __PARAM_MAP5(t1, p1, ...) t1 p1, __PARAM_MAP4(__VA_ARGS__)
#define __PARAM_MAP6(t1, p1, ...) t1 p1, __PARAM_MAP5(__VA_ARGS__)
-#define ___DOINT33(callcode, rettype) \
- int v; \
- asm volatile("int %1\n" : "=a"(v) : "i"(LUNAIX_SYS_CALL), "a"(callcode)); \
- return (rettype)v;
-
#define __DEFINE_LXSYSCALL(rettype, name) asmlinkage rettype __lxsys_##name()
#define __DEFINE_LXSYSCALL1(rettype, name, t1, p1) \
#define __DEFINE_LXSYSCALL(rettype, name) asmlinkage rettype __lxsys_##name()
#define __DEFINE_LXSYSCALL1(rettype, name, t1, p1) \
@@
-53,6
+48,16
@@
syscall_install();
asmlinkage rettype __lxsys_##name( \
__PARAM_MAP4(t1, p1, t2, p2, t3, p3, t4, p4))
asmlinkage rettype __lxsys_##name( \
__PARAM_MAP4(t1, p1, t2, p2, t3, p3, t4, p4))
+#define __SYSCALL_INTERRUPTIBLE(code) \
+ asm("sti"); \
+ { code }; \
+ asm("cli");
+
+#define ___DOINT33(callcode, rettype) \
+ int v; \
+ asm volatile("int %1\n" : "=a"(v) : "i"(LUNAIX_SYS_CALL), "a"(callcode)); \
+ return (rettype)v;
+
#define __LXSYSCALL(rettype, name) \
static rettype name() \
{ \
#define __LXSYSCALL(rettype, name) \
static rettype name() \
{ \
diff --git
a/lunaix-os/kernel/asm/x86/syscall.S
b/lunaix-os/kernel/asm/x86/syscall.S
index e97cc6f1fc56a383d2bbc457a0de07814472243e..0922a96a334060046d0d4983a8b784cbd56d7af2 100644
(file)
--- a/
lunaix-os/kernel/asm/x86/syscall.S
+++ b/
lunaix-os/kernel/asm/x86/syscall.S
@@
-21,6
+21,7
@@
.long __lxsys_sigreturn
.long __lxsys_sigprocmask
.long __lxsys_signal
.long __lxsys_sigreturn
.long __lxsys_sigprocmask
.long __lxsys_signal
+ .long __lxsys_pause
2:
.rept __SYSCALL_MAX - (2b - 1b)/4
.long 0
2:
.rept __SYSCALL_MAX - (2b - 1b)/4
.long 0
diff --git
a/lunaix-os/kernel/lxinit.c
b/lunaix-os/kernel/lxinit.c
index 1485c3411e4d95266642876f8481f0b9b3168173..2de87c5900d59d773499f956123eaae871ba89fe 100644
(file)
--- a/
lunaix-os/kernel/lxinit.c
+++ b/
lunaix-os/kernel/lxinit.c
@@
-50,6
+50,7
@@
_lxinit_main()
kprintf("I am child, I am about to terminated\n");
_exit(1);
}
kprintf("I am child, I am about to terminated\n");
_exit(1);
}
+ pause();
pid_t child = wait(&status);
kprintf("I am parent, my child (%d) terminated normally with code: %d.\n",
child,
pid_t child = wait(&status);
kprintf("I am parent, my child (%d) terminated normally with code: %d.\n",
child,
diff --git
a/lunaix-os/kernel/signal.c
b/lunaix-os/kernel/signal.c
index 49f1e534f6c65d06c4d0ba916847867e66cc491c..80a709831627f014aac41320b972e17b6b09b038 100644
(file)
--- a/
lunaix-os/kernel/signal.c
+++ b/
lunaix-os/kernel/signal.c
@@
-1,6
+1,7
@@
#include <lunaix/process.h>
#include <lunaix/sched.h>
#include <lunaix/signal.h>
#include <lunaix/process.h>
#include <lunaix/sched.h>
#include <lunaix/signal.h>
+#include <lunaix/status.h>
#include <lunaix/syscall.h>
extern struct scheduler sched_ctx; /* kernel/sched.c */
#include <lunaix/syscall.h>
extern struct scheduler sched_ctx; /* kernel/sched.c */
@@
-62,6
+63,7
@@
__DEFINE_LXSYSCALL1(int, sigreturn, struct proc_sig, *sig_ctx)
{
__current->intr_ctx = sig_ctx->prev_context;
__current->sig_mask &= ~__SIGNAL(sig_ctx->sig_num);
{
__current->intr_ctx = sig_ctx->prev_context;
__current->sig_mask &= ~__SIGNAL(sig_ctx->sig_num);
+ __current->flags &= ~PROC_FINPAUSE;
schedule();
}
schedule();
}
@@
-101,4
+103,17
@@
__DEFINE_LXSYSCALL2(int, signal, int, signum, sighandler_t, handler)
__current->sig_handler[signum] = (void*)handler;
return 0;
__current->sig_handler[signum] = (void*)handler;
return 0;
+}
+
+__DEFINE_LXSYSCALL(int, pause)
+{
+ __current->flags |= PROC_FINPAUSE;
+
+ __SYSCALL_INTERRUPTIBLE({
+ while ((__current->flags & PROC_FINPAUSE)) {
+ sched_yield();
+ }
+ })
+ __current->k_status = EINTR;
+ return -1;
}
\ No newline at end of file
}
\ No newline at end of file