Commit Graph

137 Commits

Author SHA1 Message Date
Matthew Leach
69f50fef18 sched: fix futures race-condition
When a future returns `Poll::Pending`, there is a window where, if a
waker is called, prior to the sched code setting the task's state to
`Sleeping`, the wake-up could be lost.  We get around this by
introducing a new state `Woken`.

A waker will set a `Running` task to this state. The sched code then
detects this and *does not* set the task's state to `Sleeping`, instead
it leaves it as running and attempts to re-schedule.
2025-12-24 18:44:41 -08:00
Matthew Leach
bd21276368 sched: don't bother with pointless state update
The caller of `switch_to_task` should have already set the task's state
to `Runnable` for it to be considered in this time slice. Ensure that is
the case with a debug_assert.
2025-12-24 18:44:41 -08:00
Matthew Leach
2e8871840d sched: ensure task is running when re-running same task
When scheduling the same task to be run, ensure that the state is set to
`Running` as it will have been set to `Runnable` before entering this
function call.
2025-12-24 18:44:41 -08:00
Matthew Leach
6abdbbb6d5 sched: move last_run update into switch_to_task 2025-12-24 18:44:41 -08:00
Ashwin Naren
7122429a20 dispatch signals (#85) 2025-12-24 12:54:40 -08:00
someone
2a1bb1cdde implement hardlinking (#88) 2025-12-24 09:43:12 -08:00
Matthew Leach
5259654e36 usertest: add test_clock_sleep (#87)
Add a test to ensure sleeping and clock getttime functions are correct.
2025-12-24 09:40:13 -08:00
Matthew Leach
efe34026fa Merge pull request #81 from arihant2math/mutex-timeouts 2025-12-24 08:08:20 +00:00
Matthew Leach
1d25f0d292 apply fix 2025-12-24 00:02:29 -08:00
someone
877dc9bf2e Implement sys_truncate (#86) 2025-12-23 22:08:16 -08:00
someone
3aef9a4e15 add chown/chmod (#84) 2025-12-23 15:19:25 -08:00
Ashwin Naren
c4f1d9acf5 support timeouts for futex 2025-12-23 13:08:37 -08:00
Ashwin Naren
888c099072 implement sys_sched_yield 2025-12-23 12:46:26 -08:00
Matthew Leach
88549fee5a sys_set_tid_address: finish implementation
Now CLONE_CHILD_CLEARTID has been implemented properly, we can finish
the implementation of `sys_set_tid_address`.
2025-12-23 11:28:44 -08:00
Matthew Leach
91c40c92ae usertest: add test_rust_mutex
Add a function to stress-test the kernels futex implementation.
2025-12-23 11:28:29 -08:00
Matthew Leach
6bada491b6 futex: check value while queue locked
Lock the futex queue when checking the value to ensure atomicity.
2025-12-23 10:21:30 -08:00
Matthew Leach
f7a02c6ccb libkernel: wakerset: add contains_token
Add a way to check whether the wakerset contains a token.
2025-12-23 10:21:30 -08:00
Matthew Leach
957b28e8a7 uaccess: implement try_copy_from_user
Implement a new function, `try_copy_from_user` which will not sleep when
a fault occures, making it safe to be called while a spinlock has been
acquired.
2025-12-23 10:21:30 -08:00
Matthew Leach
ca787aa4c3 libkernel: waker_set: return whether a waker was woken
Make `wake_one()` return `true` indicating whether a waker was woken
from the set, `false` otherwise.
2025-12-23 10:21:30 -08:00
Ashwin Naren
78440f292b update dependencies 2025-12-23 00:01:45 -08:00
Matthew Leach
8af3653e60 Merge pull request #76 from some100/master 2025-12-23 06:46:59 +00:00
ootinnyoo
8f00af7587 implement sys_fchdir 2025-12-22 18:34:22 -05:00
Matthew Leach
1dd1811f34 Merge pull request #75 from arihant2math/fix-thread-join 2025-12-22 17:36:48 +00:00
Ashwin Naren
2cb93c0891 address review 2025-12-22 02:06:11 -08:00
Ashwin Naren
8bf0a72bce fix futex based thread joining 2025-12-21 17:02:19 -08:00
Matthew Leach
e77742e029 aarch64: syscalls: clone: fix arg order
The clone syscal on aarch64 is the following:

```
SYS_clone, flags, stack, ptid, tls, ctid
x8,        x0,    x1,    x2,   x3,  x4
```

which is a different order than listed on the man page. Fix the ordering
in the aarch64 syscall dispatch code.
2025-12-21 16:13:15 -08:00
Matthew Leach
3273d6451e clone: implement CLONE_SETTLS
Set the TLS pointer when `CLONE_SETTLS` is set in `sys_clone`.
2025-12-21 16:13:15 -08:00
Matthew Leach
12076c7ad2 usertest: add test_rust_thread
Add a simple thread spawn test.
2025-12-21 16:13:15 -08:00
Matthew Leach
a7ebe8e214 threading: fix clone to spawn threads
Fix issues identify in `sys_clone` logic to enable basic threading.
2025-12-21 16:13:15 -08:00
Matthew Leach
eb2369f621 Merge pull request #57 from arihant2math/futex 2025-12-21 13:30:40 +00:00
Matthew Leach
03a400d2bd Merge pull request #72 from some100/master 2025-12-21 13:30:05 +00:00
Ashwin Naren
637874620b address review 2025-12-21 01:56:33 -08:00
Ashwin Naren
73b9afc2f0 remove redundant rust mutex test 2025-12-21 01:44:30 -08:00
Ashwin Naren
f004824bbd make clippy happy 2025-12-21 01:43:54 -08:00
Ashwin Naren
b7e8e9edcc add note 2025-12-21 01:43:54 -08:00
Ashwin Naren
a6efc75686 final fixes 2025-12-21 01:43:54 -08:00
Ashwin Naren
d60e70e397 add another usertest
 Conflicts:
	usertest/src/main.rs
2025-12-21 01:43:54 -08:00
Ashwin Naren
93df6b0ebc get data w/ spinlock 2025-12-21 01:43:54 -08:00
Ashwin Naren
cb6dbdf5bb futex impl 2025-12-21 01:43:54 -08:00
Ashwin Naren
3fbb56098c futex impl
# Conflicts:
#	usertest/src/main.rs
2025-12-21 01:43:54 -08:00
Ashwin Naren
cd6d830ae9 Initial proc fs (#70) 2025-12-21 01:37:14 -08:00
ootinnyoo
237ab737df implement sys_chroot 2025-12-20 19:06:07 -05:00
Ashwin Naren
35a6caa541 Implement sys_sysinfo (#71) 2025-12-20 15:42:08 -08:00
Ashwin Naren
b98a54b928 Stub sys_madvise (#67) 2025-12-19 15:28:43 -08:00
Ashwin Naren
fd65436604 Add rust file/dir usertest (#65) 2025-12-18 16:19:42 -08:00
Ashwin Naren
781b9b5c3f implement mkdir and unlink
rm, mkdir and rmdir now work in tmpfs
2025-12-18 15:35:09 +00:00
Ashwin Naren
b8ad29b4b1 update .gitignore 2025-12-17 20:07:53 -08:00
Matthew Leach
9db6162414 formatting 2025-12-17 20:04:31 -08:00
Matthew Leach
0a32eeaaa0 scripts: create /tmp
Create /tmp and modify the kernel command line to mount tmpfs on /tmp.
2025-12-17 20:04:31 -08:00
Matthew Leach
5511e28b72 syscalls: implement ftruncate 2025-12-17 20:04:31 -08:00