Skip to content

[SUBISSUE #3] Implement POSIX Clocks, High-Resolution Sleep, and Interval/Per-Process Timers #294

Todo

Description

@marcobuschini

Parent Issue / Epic

#282 (Epic #265)

Prerequisite Sub-Issue

#286

Atomic Deliverable & Implementation Details

Complete POSIX clock and timer syscalls (noting clock_gettime 113, nanosleep 101, and gettimeofday 169 are already implemented):

  • kernel/uapi/time.hpp: Define linux_itimerval (32 bytes), ITIMER_REAL/ITIMER_VIRTUAL/ITIMER_PROF, TIMER_ABSTIME, and linux_sigevent (64 bytes) with static_assert checks.
  • kernel/process/Process.hpp & kernel/process/Process.cpp: Track per-process ITIMER_REAL deadline/interval and per-process POSIX timer slots (firing SIGALRM or configured sigev_signo from periodic timer ticks / poll checks).
  • kernel/syscalls/TimeSyscalls.cpp & SyscallDispatcher.cpp: Implement and dispatch getitimer (102), setitimer (103), timer_create (107), timer_gettime (108), timer_getoverrun (109), timer_settime (110), timer_delete (111), clock_getres (114), and clock_nanosleep (115).
  • tests/host/ & kernel/shell/tests/: Add host ASan/UBSan tests (using HostTest::advance_timer_ticks) and QEMU timer-signal verification.

Out of scope: timerfd_* (already implemented in #264).

Acceptance Criteria & Edge Cases

  • clock_getres returns exact hardware timer tick resolution for CLOCK_REALTIME and CLOCK_MONOTONIC (and -EINVAL for invalid clock IDs)
  • clock_nanosleep supports relative and TIMER_ABSTIME sleeps, writes remaining time on EINTR (relative mode only), and returns positive errno / negated syscall return cleanly per Linux AArch64 ABI
  • setitimer(ITIMER_REAL) delivers SIGALRM on expiry and supports periodic reloading and disarming (0, 0)
  • timer_create / timer_settime / timer_gettime / timer_getoverrun / timer_delete clean up all timer slots on process exit with zero leaks
  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings

Metadata

Metadata

Assignees

Labels

subissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions