mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
syscalls: fchdir, setitimer, getitimer
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#ifndef _ITIMER_H
|
||||
#define _ITIMER_H
|
||||
|
||||
#include <kernel/dpc.h>
|
||||
#include <kernel/timer.h>
|
||||
|
||||
typedef struct {
|
||||
struct cpu_t *cpu;
|
||||
timerentry_t entry;
|
||||
uintmax_t remainingus;
|
||||
uintmax_t repeatus;
|
||||
dpcfn_t fn;
|
||||
dpcarg_t arg;
|
||||
bool paused;
|
||||
spinlock_t lock;
|
||||
} itimer_t;
|
||||
|
||||
void itimer_init(itimer_t *itimer, dpcfn_t fn, dpcarg_t arg);
|
||||
void itimer_pause(itimer_t *itimer, uintmax_t *remainingus, uintmax_t *repeatus);
|
||||
void itimer_set(itimer_t *itimer, uintmax_t timerus, uintmax_t repeatus);
|
||||
void itimer_resume(itimer_t *itimer);
|
||||
|
||||
#endif
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <semaphore.h>
|
||||
#include <mutex.h>
|
||||
#include <kernel/signal.h>
|
||||
#include <kernel/itimer.h>
|
||||
|
||||
#define SCHED_THREAD_FLAGS_QUEUED 1
|
||||
#define SCHED_THREAD_FLAGS_RUNNING 2
|
||||
@@ -112,6 +113,13 @@ typedef struct proc_t {
|
||||
bool stopunwaited;
|
||||
bool continueunwaited;
|
||||
} signals;
|
||||
|
||||
struct {
|
||||
mutex_t mutex;
|
||||
itimer_t realtime;
|
||||
itimer_t virtualtime;
|
||||
itimer_t profiling;
|
||||
} timer;
|
||||
} proc_t;
|
||||
|
||||
#include <arch/cpu.h>
|
||||
|
||||
@@ -4,12 +4,18 @@
|
||||
#include <util.h>
|
||||
|
||||
typedef long time_t;
|
||||
typedef long suseconds_t;
|
||||
|
||||
typedef struct {
|
||||
time_t s;
|
||||
time_t ns;
|
||||
} timespec_t;
|
||||
|
||||
typedef struct {
|
||||
time_t s;
|
||||
suseconds_t us;
|
||||
} timeval_t;
|
||||
|
||||
static inline timespec_t timespec_add(timespec_t a, timespec_t b) {
|
||||
timespec_t ts;
|
||||
ts.ns = (a.ns + b.ns) % 1000000000;
|
||||
|
||||
Reference in New Issue
Block a user