Commit Graph

138 Commits

Author SHA1 Message Date
9dc5a4d28f Box the large structure AnyUnboundSocket
So far it is quite common to put the `AnyUnboundSocket` in an enum
variant, e.g. the following code snippet.
```rust
enum Inner {
    Unbound(AlwaysSome<Box<AnyUnboundSocket>>),
    Bound(AlwaysSome<Arc<AnyBoundSocket>>),
    // ...
}
```

However, this pattern is very memory inefficient because the size
difference between two enum variants is significant. The size of
`AnyUnboundSocket` is much larger than the size of
`Arc<AnyBoundSocket>`, where the latter is simply a pointer and a
reference counter.

In fact, we're about to trigger Clippy's large_enum_variant warning.
We're just below its threshold, so the warning doesn't appear.

The solution is simple: If we put `AnyBoundSocket` in `Arc`, we should
also put `AnyUnboundSocket` in `Box`. This way the sizes of different
enum variants will be similar.
2023-12-26 06:51:25 +08:00
02e10705af Use Arc to pack bound datagram structure
For TCP streams we have packed their different states with `Arc`, e.g.
`InitStream`, `ConnectedStream`, and `ListenStream`. Later we will
implement an trait that observes iface events for some of these states.

For UDP datagrams, they can be in the unbound state and the bound state.
If we want to implement the observer trait for the bound state, we need
to wrap it with `Arc` so that it can be registered with
`AnyBoundSocket`.

Alternatively, we can implement the observer trait directly on the UDP
datagram structure (i.e. `DatagramSocket`). However, there are literally
no events to handle if the socket is not bound at all (i.e. it is in the
unbound state). So a more efficient way is to implement the observer
trait only for the bound state, which motivates changes in this commit.
2023-12-26 06:51:25 +08:00
246d8521f2 Rename the nonblocking method to is_nonblocking
We used to use `is_nonblocking()` in TCP streams, but use
`nonblocking()` in UDP datagrams.

Since `is_nonblocking()` is generally preferred, this commit renames
`nonblocking()` to `is_nonblocking()` in UDP datagrams.
2023-12-26 06:51:25 +08:00
47d2a895af Fix a bug and support more clockids in vdso. 2023-12-20 16:20:07 +08:00
2ad9735eab Support VDSO in Jinux 2023-12-06 19:31:19 +08:00
715072b9f3 Implement a high precision gettime based on tsc 2023-12-06 19:31:19 +08:00
65ef055f4e impl From<TdCallError> for Error 2023-12-06 18:50:53 +08:00
2d0f5253e9 Add error handling 2023-12-06 18:50:53 +08:00
55ea3dc86f Add tdx-guest device 2023-12-06 18:50:53 +08:00
a91a35ebce Support alternate signal stack 2023-12-06 12:54:03 +08:00
3734306398 Refactor signal code 2023-12-06 11:01:54 +08:00
90be8038e0 Add credential-related syscalls 2023-12-06 11:01:54 +08:00
c99e6b4ced Implememt static cap credentials 2023-12-06 11:01:54 +08:00
5aa3124e66 Make the upgrade method of read-write locks atomic 2023-12-06 10:40:11 +08:00
ce5730287e Refactor session & tty code 2023-11-28 12:11:54 +08:00
3bde0f6bb7 Add unit test for session and group 2023-11-28 12:11:54 +08:00
9d8a2b420d Refactor tty&pty code 2023-11-28 12:11:54 +08:00
001326110e Add trait FileIo and refactor current devices 2023-11-28 12:11:54 +08:00
43fd1a52fa Add syscall getsid, setsid and refactor other syscalls 2023-11-28 12:11:54 +08:00
9040fb54ea Add basic structures for session, terminal and job control 2023-11-28 12:11:54 +08:00
2edbe1f725 Add as_device method for file handle 2023-11-28 12:11:54 +08:00
232888982c Rename TrapInformation 2023-11-23 09:15:37 +08:00
edd808bd3d Refactor drivers 2023-11-23 09:15:37 +08:00
34e66a51d9 Reimplement print in std 2023-11-23 09:15:37 +08:00
01e485b96e Support virtio console device 2023-11-23 09:15:37 +08:00
45a6b2f46c Implement should_panic for ktest and clear the codebase 2023-11-09 13:22:34 +08:00
b8818bb740 Add ktest framework 2023-11-09 13:22:34 +08:00
d7cc52c615 Update the version of pod 2023-11-09 03:38:37 +08:00
4c72f5b7fa Add VmSegment and rewrite the vm allocation code with VmAllocOptions 2023-11-08 06:31:21 +08:00
040f5a53ae Fix panic when listen backlog is one 2023-11-03 08:52:39 +08:00
f6c230f756 Fix endless loops when send buffer is full 2023-11-03 08:51:37 +08:00
eeac55e2e5 Refactor console 2023-10-30 09:39:23 +08:00
9c52f7aee7 Fix the incorrect nlinks decrease in ramfs 2023-10-23 07:48:26 +08:00
97c2f5065e Fix the memory ordering in subject 2023-10-17 00:23:37 -05:00
98bf3d4845 Remove Vnode to let the fs use PageCache for itself 2023-10-16 18:12:48 -05:00
6ff4601482 Fix: raw mode tty can echo and send signal 2023-10-12 14:35:39 -05:00
342bbdc0c4 Fix panic problem in tty driver 2023-10-10 16:52:40 -05:00
0d6f6f001c Refactor the implementation 2023-10-10 16:52:40 -05:00
50761a5cc5 Support wait_interruptible for Poller 2023-10-10 16:52:40 -05:00
d2aa06cbe2 Support wait_interruptible with SigQueueObserver 2023-10-10 16:52:40 -05:00
ec857e5205 Add timeout parameter for poller.wait 2023-10-10 16:52:40 -05:00
bd6a4d34ff Support timeout for WaitQueue 2023-10-10 16:52:40 -05:00
d28f0db419 Refactor tty driver using the work queue 2023-10-09 18:08:15 -05:00
7419f6b56b Add the bottom half mechanism of workqueue 2023-10-09 18:08:15 -05:00
e2b4302620 Add basic preemptive scheduling 2023-10-09 18:08:15 -05:00
baeaa9b4d3 Rename fork_vmar to fork_from 2023-09-28 11:53:53 +08:00
12fc074f56 Add tdx-guest crate 2023-09-28 03:47:55 +08:00
f540345bfd Use builder pattern to refactor the process module 2023-09-15 06:45:41 +08:00
9ca64c281e Fix clippy and compiler warings 2023-09-05 18:42:06 +08:00
038c19b693 Refactor the pty implementation 2023-09-05 06:24:54 +08:00