__LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
+__LXSYSCALL(int, pause)
+
#endif /* __LUNAIX_UNISTD_H */
#define PROC_TERMMASK 0x6
+#define PROC_FINPAUSE 1
+
struct proc_mm
{
heap_context_t u_heap;
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;
#define LXSEGFAULT -(5)
#define LXINVL -(6)
+#define EINTR -(7)
+
#endif /* __LUNAIX_CODE_H */
#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) \
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() \
{ \
.long __lxsys_sigreturn
.long __lxsys_sigprocmask
.long __lxsys_signal
+ .long __lxsys_pause
2:
.rept __SYSCALL_MAX - (2b - 1b)/4
.long 0
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,
#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 */
{
__current->intr_ctx = sig_ctx->prev_context;
__current->sig_mask &= ~__SIGNAL(sig_ctx->sig_num);
+ __current->flags &= ~PROC_FINPAUSE;
schedule();
}
__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