Commit graph

1211 commits

Author SHA1 Message Date
Tom 5f51d85184 Kernel: Improve time keeping and dramatically reduce interrupt load
This implements a number of changes related to time:
* If a HPET is present, it is now used only as a system timer, unless
  the Local APIC timer is used (in which case the HPET timer will not
  trigger any interrupts at all).
* If a HPET is present, the current time can now be as accurate as the
  chip can be, independently from the system timer. We now query the
  HPET main counter for the current time in CPU #0's system timer
  interrupt, and use that as a base line. If a high precision time is
  queried, that base line is used in combination with quering the HPET
  timer directly, which should give a much more accurate time stamp at
  the expense of more overhead. For faster time stamps, the more coarse
  value based on the last interrupt will be returned. This also means
  that any missed interrupts should not cause the time to drift.
* The default system interrupt rate is reduced to about 250 per second.
* Fix calculation of Thread CPU usage by using the amount of ticks they
  used rather than the number of times a context switch happened.
* Implement CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE and use it
  for most cases where precise timestamps are not needed.
2020-12-21 18:26:12 +01:00
Brendan Coles a3fdf5148b Userland: userdel: Resolve home directory realpath before removal 2020-12-21 12:23:50 +01:00
Brendan Coles 39c92dad83 Userland: useradd: Add command line option to set user password 2020-12-21 09:57:26 +01:00
Lenny Maiorani 765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling b30acdb4b7 LibTLS+Userland: Remove all uses of ByteBuffer::slice_view()
This was another way to get a non-owning ByteBuffer wrapper.
2020-12-19 18:29:13 +01:00
Andreas Kling d5600e966a LibTLS+LibCrypto: Remove all remaining uses of ByteBuffer::wrap() 2020-12-19 18:29:13 +01:00
Andreas Kling a8dbfc3398 LibCrypto: Yet more ByteBuffer::wrap() removal. Not much left now! 2020-12-19 18:29:13 +01:00
Andreas Kling e517505e35 LibTLS: Even more ByteBuffer -> Span conversion 2020-12-19 18:29:13 +01:00
Andreas Kling f82b0a78ef LibTLS+LibCrypto: More ByteBuffer -> Span conversion 2020-12-19 18:29:13 +01:00
Andreas Kling 8e20208dd6 LibTLS+LibCrypto: Replace a whole bunch of ByteBuffers with Spans 2020-12-19 18:29:13 +01:00
Andreas Kling 685d5f4e25 LibProtocol: Remove use of ByteBuffer::wrap() in protocol API 2020-12-19 13:09:02 +01:00
Brendan Coles 853664bd3c LibC: stdlib: Add clearenv() function 2020-12-17 19:39:56 +01:00
Andreas Kling 56701f91f9 ln: Make the 'path' argument optional
If 'path' is omitted, we create a link with the basename of whatever
the target is. This matches what other systems do.
2020-12-16 23:26:35 +01:00
Brendan Coles b9d99849ad Userland: Add beep utility 2020-12-16 17:29:28 +01:00
Itamar d2a984f2c7 Loader: Don't re-load self-dependant libraries 2020-12-14 23:05:53 +01:00
Itamar 72ca45e300 UserspaceEmulator: Support dynamically loaded programs
When loading dynamic objects, the emulator loads the interpreter,
generates an auxiliary vector and starts executing the loader.

Additionally, this commits also makes the MallocTracer and backtrace
symbolication work for dynamically loaded programs.
2020-12-14 23:05:53 +01:00
Itamar f12e13e81c Loader: Take main program name from auxiliary vector 2020-12-14 23:05:53 +01:00
Itamar efe4da57df Loader: Stabilize loader & Use shared libraries everywhere :^)
The dynamic loader is now stable enough to be used everywhere in the
system - so this commit does just that.
No More .a Files, Long Live .so's!
2020-12-14 23:05:53 +01:00
Itamar 07b4957361 Loader: Add dynamic loader program
The dynamic loader exists as /usr/lib/Loader.so and is loaded by the
kernel when ET_DYN programs are executed.

The dynamic loader is responsible for loading the dependencies of the
main program, allocating TLS storage, preparing all loaded objects for
execution and finally jumping to the entry of the main program.
2020-12-14 23:05:53 +01:00
Linus Groh b04e0a7677 jp: Remove trailing comma at end of object/array to make output valid JSON
It's ironic that `jp` currently refuses to parse its own output :^)
2020-12-14 20:25:01 +01:00
Linus Groh c07176bd53 jp: Only output colors when stdout is a TTY 2020-12-14 20:25:01 +01:00
Linus Groh e68f4111ea jp: Use new format functions 2020-12-14 20:25:01 +01:00
Andreas Kling 22c582a887 LibWeb: Make HTMLDocumentParser take an existing document
We shouldn't really be creating the document objects inside the parser,
since that makes it hard to hook up e.g JavaScript bindings early on.
2020-12-13 16:59:22 +01:00
Andreas Kling b9b7b2b28a LibCore: Make IODevice::read_line() return a String
Almost everyone using this API actually wanted String instead of a
ByteBuffer anyway, and there were a bunch of slightly different ways
clients would convert to String.

Let's just cut out all the confusion and make it return String. :^)
2020-12-13 11:54:11 +01:00
Tom bcb9363a97 LibPthread: Return errors as positive return values
pthread implementations generally return errors as a positive non-zero
value. Our kernel generally returns errors as negative values. If we
receive a negative value from a system call, turn it into a positive
return value to relay the error appropriately.

Also, fix the tt test utility to not rely on errno, as the pthread
library does not use errno.
2020-12-12 21:28:12 +01:00
Sahan Fernando 9453032bf6
Userland: Fix overly-eager loop detection in cp (#4368)
The bug is that if you try to cp DIR_A to DIR_B where DIR_A and DIR_B
have the same parent directory and DIR_A's name is a prefix of DIR_B
(e.g. foo -> foo2, bar -> barbar), it thinks that it's a subdirectory
(since it checks if DIR_A's realpath is a prefix of DIR_B's realpath).

The easiest solution is to put a path delimiter at the end before the
comparison, since you can't have a / in the middle of a directory name.

For example if DIR_A is /home/anon/foo and DIR_B is /home/anon/foo2,
then DIR_A's realpath is a prefix of DIR_B's realpath even though DIR_B
is not inside DIR_A.
2020-12-09 20:56:50 +01:00
Sahan Fernando a3bcff0db8 Userland: Fix segfault in sort 2020-12-09 20:55:06 +01:00
Ben Wiederhake 8f392683c7 Userland: Fix typo in 'pro' help 2020-12-06 15:50:02 +01:00
Ben Wiederhake 4ec77ba929 Userland: Write some '--help' descriptions where appropriate 2020-12-06 00:06:53 +01:00
Linus Groh 745801e109 js: Improve pretty-printing of various objects
For many object types we only ever used the regular print_object() in
the js REPL - resulting in a useless "{  }".

This patch adds more individual representations for the following types:
- Boolean/Number/String object: print wrapped value
- ArrayBuffer: print byteLength and hex-formatted bytes in chunks of 16
- TypedArray: print length, byteLength, buffer pointer and values
- Proxy: print target and handler

Also improve the existing pretty-printing output:
- More consistency, most objects now follow the format "[Type] ..."
- Some coloring tweaks
- No two spaces in empty arrays & objects

Possible future improvements:
- Add line breaks between elements of long arrays & objects

Closes #4310.
2020-12-05 10:05:28 +01:00
Linus Groh 1fab67ea52 test-js: Use new format functions 2020-12-03 21:55:02 +01:00
Linus Groh 7cbdf465ba test-js: Set test root correctly when specified as positional arg
When a test root path was given to test-js it was never used, causing
test-js to always fail.
2020-12-03 21:55:02 +01:00
Julian Offenhäuser bad8cd3d8f Applications+Userland: Switch to new Audio::Loader API 2020-12-02 16:31:30 +01:00
Tom 046d6855f5 Kernel: Move block condition evaluation out of the Scheduler
This makes the Scheduler a lot leaner by not having to evaluate
block conditions every time it is invoked. Instead evaluate them as
the states change, and unblock threads at that point.

This also implements some more waitid/waitpid/wait features and
behavior. For example, WUNTRACED and WNOWAIT are now supported. And
wait will now not return EINTR when SIGCHLD is delivered at the
same time.
2020-11-30 13:17:02 +01:00
AnotherTest b45f3ea0f8 Userland: Implement -I/-a (binary-mode) and -i (insensitive) for grep
This fixes #4195 and closes #4196.
2020-11-29 20:32:10 +01:00
AnotherTest 129a58a2e5 LibCore: Do not try to null-terminate a ByteBuffer in read_line()
That's just silly :)
Also fix that one use of read_line() which assumes it will
null-terminated in mount.cpp (this would've blown up if the IODevice was
at EOF and had a line with the same size as max_size).
2020-11-29 20:32:10 +01:00
Lenny Maiorani a34939bcd5
Tests/Kernel: Remove redundant if (#4111)
Problem:

- If `fork()` fails the system tries to call `execl()`. That will
  either succeed and replace the running process image or it will fail
  and it needs to try again. The `if` is redundant because it will
  only be evaluated if `execl()` fails.

Solution:
- Remove the `if`.
2020-11-29 10:41:02 +01:00
AnotherTest ee548ca5b9 Userland: Make mv capable of moving multiple files
Closes #4188.
2020-11-29 10:14:43 +01:00
Sergey Bugaev 952c0dc2a0 Userland: Implement find -name clause
Closes https://github.com/SerenityOS/serenity/issues/4191
2020-11-28 14:28:58 +01:00
Brendan Coles 2adcdbcc1e Tests: Add Kernel tests for unveil system call browse 'b' flag 2020-11-28 10:08:00 +01:00
AnotherTest 3200ff5f4f LibJS+js: Rename RegExp.{content => pattern}
The spec talks about it as 'pattern', so let's use that instead.
2020-11-27 21:32:41 +01:00
AnotherTest 45e5661296 Userland: Add support for 'match' in 'expr' 2020-11-27 21:32:41 +01:00
Emanuel Sprung 12dd40a2a5 Userland: Add grep utility
Grep supports only extended regular expressions, and is able to handle one pattern
handed over via -e or directly after the options. Also, multiple files can be
handed over. Recursive mode is outstanding, but no real magic :^)
2020-11-27 21:32:41 +01:00
Andreas Kling ffa4405083 LibPthread: Fix broken EINVAL check in pthread_attr_setdetachstate()
Also fix up some misleading error messages in the 'tt' test program.
2020-11-26 19:33:44 +01:00
Andreas Kling a5e560ee49 test-js: Don't keep a pointer to a temporary String's characters
This was only an issue in the Lagom build.
2020-11-26 19:33:35 +01:00
Sergey Bugaev b1fd06eb4c Userland: Add a test for pthread_once() 2020-11-24 21:36:28 +01:00
BenJilks 91b2af34e1 base64: Fix not outputting all decoded data
It would use printf to output the data, so if it contains a null
terminator it'll stop.
2020-11-22 16:07:00 +01:00
Lenny Maiorani 446a19ba51
test-crypto: Remove foo.response file created by testing (#4110)
Problem:
- Test creates a file and leaves it in the source tree.

Solution:
- Remove the creation of the file since it is never checked.
2020-11-20 21:18:43 +01:00
Spencer Dixon f23d9a73aa Userland: Add -v verbose flag to 'rm' 2020-11-17 09:40:03 +01:00
Spencer Dixon 2dab9d4bac Userland: Add -v verbose flag to 'mv' 2020-11-17 09:40:03 +01:00