Commit Graph

238 Commits

Author SHA1 Message Date
12b93567f7 Kernel/LibC: Implement getpeername 2025-05-28 03:10:01 +03:00
44b762f916 Kernel/LibC: Implement pwrite and make pread non-locking 2025-05-28 03:10:01 +03:00
1bcd1edbf5 Kernel/LibC: Implement basic epoll
This implementation is on top of inodes instead of fds as linux does it.
If I start finding ports/software that relies on epoll allowing
duplicate inodes, I will do what linux does.

I'm probably missing multiple epoll_notify's which may cause hangs but
the system seems to work fine :dd:
2025-05-13 10:18:05 +03:00
143a00626b Kernel: Fix fork cmdline copying and copy environ 2025-05-13 10:16:21 +03:00
f8e3ae0525 Kernel: Fix deadlock caused by multithreading
This allows multiple threads to concurrently call the most common
blocking syscalls:
- read
- write
- accept
- connect
- sendto
- recv
- pselect

This prevents a dead lock when for example process is waiting on a pipe,
but unable to write to it since process is locked.

This is the beginning of starting to remove processes own lock from
syscall and locking only necessary parts.
2025-04-22 04:51:53 +03:00
6f9dc2a9b8 Kernel/LibC: Implement fchdir, cleanup chdir and getcwd 2025-04-19 21:28:31 +03:00
ac90800c3c Kernel/LibC/DynamicLoader: Implement thread local storage
For some reason this does not work on 32 bit version, so it is disabled
on that platform. I'll have to look into it later to find the bug :)
2025-04-15 23:33:39 +03:00
4bcd3ed86f Kernel: Start working on TLS, add SYS_{SET,GET}_TLS 2025-04-15 23:31:17 +03:00
36baf7b0af Kernel/LibC/DynamicLoader: Update process start ABI
We now use SysV abi for process startup
2025-04-15 23:05:52 +03:00
be786be67d Kernel/LibC: Implement pthread_join 2025-04-02 12:58:39 +03:00
9066e62a97 Kernel/LibC: Implement sched_yield 2025-04-02 12:58:39 +03:00
5549696c3a Kernel/LibC: Implement pthread_self 2025-04-02 02:39:29 +03:00
c1618e2b5d Kernel/LibC: Add basic support for pthread_{create,exit} 2025-04-01 23:26:13 +03:00
9893c90e74 Kernel: Remove SYS_DUP and implement it using fcntl F_DUPFD 2025-01-17 19:29:47 +02:00
2d0690ae2d Kernel: Cleanup most of syscalls dealing with files 2024-12-07 05:33:04 +02:00
713daf6cd3 Kernel/LibC: Add support for creating hardlinks 2024-12-03 16:12:26 +02:00
d58ca5f37a Kernel/LibC: Implement symlink{,at} 2024-12-02 20:13:38 +02:00
a10ca47657 Kernel/LibC: Implement {,f}statvfs 2024-12-02 20:13:37 +02:00
ad1f175a39 Kernel/LibC: Implement getppid 2024-12-02 20:13:37 +02:00
6ed1435aeb Kernel/LibC: Implement tcgetpgrp 2024-12-02 20:13:37 +02:00
747c3b2a4b Kernel/LibC: Implement fsync 2024-12-02 20:13:37 +02:00
88a86a9927 Kernel: Fix Thread destruction after sys_exit
This had undefined behaviour as Thread's (Processes's) PageTable was
destroyed before Thread had the change to destroy its own stacks that
lived on the PageTable.
2024-11-26 00:59:34 +02:00
aaff5a65e1 Kernel/init: /dev/tty is now custom symlink to controlling terminal
kernel now passes the name of default console to init process so init
knows which file to open as stdio. before /dev/tty was referencing the
system wide current terminal which was inherited from cmdline. This
doesn't work anymore as we have pseudo terminals implemented that can
chage the current terminal during runtime :D
2024-11-17 22:38:52 +02:00
458a362f98 Kernel: Allow kernel to pass arguments to init process 2024-11-17 22:38:02 +02:00
348d04f7f5 Kernel: Implement static Process::kill()
This allows killing processes even when there does not exist a current
thread.
2024-09-24 13:16:43 +03:00
b779b3cf2d Kernel: Move file finding code to a helper 2024-09-17 18:52:52 +03:00
e431e90b20 Kernel/LibC: Implement all chown family function with fchownat 2024-09-17 18:35:01 +03:00
4aa466b948 Kernel/LibC: Implement all chmod family functions using fchmodat 2024-09-17 17:19:26 +03:00
3666525d24 Kernel/LibC: Implement readlink in terms of readlinkat 2024-09-17 16:38:15 +03:00
f1a4bbce53 Kernel/LibC: Implement all stat family functions with fstatat
This patch gets rid of 2 unnecessary syscalls!
2024-09-17 16:38:01 +03:00
708a720d9d Kernel: Remove SYS_OPEN
This can be done with SYS_OPENAT with fd set to AT_FDCWD
2024-09-17 16:16:47 +03:00
d88ee5c9ee Kernel/LibC: Implement creat with open
This allows getting rid of unnecessary SYS_CREATE. Directory creation
still has its own syscall, but I could combine it with SYS_OPEN also.
2024-09-17 15:55:53 +03:00
a084f83f4c Kernel: Rework kernel-side ELF loading
ELFs are now loaded as MemoryRegions so they don't need special handling
anywhere. This also allows file backed COW optimizations to work. This
was not the case before.

This patch removes now obsolete LoadableELF and unused ELF files from
LibElf.
2024-09-15 23:57:34 +03:00
8956835d95 Kernel: Make sys_.*at use VFS relative path finding 2024-09-14 21:15:58 +03:00
3a352078de Kernel: Make VirtualFileSystem::File non copyable 2024-09-14 20:09:28 +03:00
467ac6c365 Kernel/LibC: Implement SOCK_CLOEXEC and SOCK_NONBLOCK
This removes the need for fcntl after creating a socket :)
2024-09-11 21:59:11 +03:00
c77ad5fb34 Kernel: Implement copy-on-write memory for file backed mmaps 2024-09-11 19:33:50 +03:00
2bf65ef512 Kernel: Invoke ELF interpreter instead if it is specified 2024-08-28 17:06:32 +03:00
991ae4383a Kernel/LibC: Implement fchmod 2024-08-25 15:07:42 +03:00
a5a097fa4a Kernel/LibC: Add initial pseudo terminal support
This patch implements posix_openpt() and ptsname()

grantpt() and unlockpt() are left in LibC as stubs, as posix_openpt
currently does all of the needed work.
2024-08-11 01:02:59 +03:00
ad645f31d0 Kernel/LibC: Add setsid() 2024-08-11 00:58:12 +03:00
1c67b5e812 Kernel: Fix wait syscall to report status of exited children 2024-08-09 16:52:35 +03:00
a33b63d066 Kernel/LibC: Implement alarm() and setitimer()
This makes vim able to start!
2024-08-01 21:09:56 +03:00
6de350ce9d Kernel/LibC: Cleanup, fix and implement a lot of signal code
This patch implements sigsets and some of their usages
2024-08-01 17:01:18 +03:00
f0be4f86a6 LibC/Kernel: Implement access 2024-07-30 11:51:07 +03:00
e5bb843059 LibC/Kernel: Implement ttyname 2024-07-30 11:41:18 +03:00
681d8327f5 LibC/Kernel: Cleanup termios code
This is still not correct, but much better than it used to be
2024-07-30 11:10:43 +03:00
f8261c60c0 Kernel: Rewrite the whole scheduler and re-architecture SMP handling
Change Semaphore -> ThreadBlocker
  This was not a semaphore, I just named it one because I didn't know
  what semaphore was. I have meant to change this sooner, but it was in
  no way urgent :D

Implement SMP events. Processors can now be sent SMP events through
IPIs. SMP events can be sent either to a single processor or broadcasted
to every processor.

PageTable::{map_page,map_range,unmap_page,unmap_range}() now send SMP
event to invalidate TLB caches for the changed pages.

Scheduler no longer uses a global run queue. Each processor has its own
scheduler that keeps track of the load on the processor. Once every
second schedulers do load balancing. Schedulers have no access to other
processors' schedulers, they just see approximate loads. If scheduler
decides that it has too much load, it will send a thread to another
processor through a SMP event.

Schedulers are currently run using the timer interrupt on BSB. This
should be not the case, and each processor should use its LAPIC timer
for interrupts. There is no reason to broadcast SMP event to all
processors when BSB gets timer interrupt.

Old scheduler only achieved 20% idle load on qemu. That was probably a
very inefficient implementation. This new scheduler seems to average
around 1% idle load. This is much closer to what I would expect. On my
own laptop idle load seems to be only around 0.5% on each processor.
2024-07-22 00:33:50 +03:00
af4b138094 Kernel/LibC: Implement realpath
realpath is implemented as a syscall. This is not really required but it
was the easiest way to get it working as there is already path
canonicalization at kernel level.
2024-06-25 19:32:40 +03:00
be7ed8e74a Kernel/LibC: Implement {get,set}sockopt()
These are pretty much dummy functions in the kernel side. Only case that
is handled is SOL_SOCKET with SO_ERROR. This is hard coded to return no
error. Network stack is currently synchronous, so all errors are already
reported through synchronous network functions.
2024-06-17 20:56:48 +03:00