syscalls: fchdir, setitimer, getitimer

This commit is contained in:
Matheus
2024-05-29 11:10:24 -03:00
parent 5b5d300fc1
commit 5f7791cd08
11 changed files with 313 additions and 13 deletions
+23
View File
@@ -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
View File
@@ -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>
+6
View File
@@ -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;