1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:07:45 +00:00

Add a "sleep" syscall that sleeps for N seconds.

This commit is contained in:
Andreas Kling 2018-10-25 13:53:49 +02:00
parent c6f2890d8e
commit 5978185242
11 changed files with 37 additions and 12 deletions

View file

@ -24,9 +24,9 @@ bool ProcFileSystem::initialize()
auto stringImpl = StringImpl::createUninitialized(tasks.size() * 256, buffer);
memset(buffer, 0, stringImpl->length());
char* ptr = buffer;
ptr += ksprintf(ptr, "PID OWNER STATE PPID NSCHED FDS NAME\n");
ptr += ksprintf(ptr, "PID OWNER STATE PPID NSCHED FDS NAME\n");
for (auto* task : tasks) {
ptr += ksprintf(ptr, "%w %w:%w %b %w %w %w %s\n",
ptr += ksprintf(ptr, "%w %w:%w %b %w %x %w %s\n",
task->pid(),
task->uid(),
task->gid(),

View file

@ -61,7 +61,6 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3)
Console::the().putChar(arg1 & 0xff);
break;
case Syscall::Sleep:
//kprintf("syscall: sleep(%d)\n", arg1);
current->sys$sleep(arg1);
break;
case Syscall::Spawn:

View file

@ -10,6 +10,7 @@
#include <ELFLoader/ExecSpace.h>
#include "MemoryManager.h"
#include "errno.h"
#include "i8253.h"
//#define DEBUG_IO
//#define TASK_DEBUG
@ -719,6 +720,14 @@ int Task::sys$kill(pid_t pid, int sig)
return -1;
}
int Task::sys$sleep(unsigned seconds)
{
if (!seconds)
return 0;
sleep(seconds * TICKS_PER_SECOND);
return 0;
}
uid_t Task::sys$getuid()
{
return m_uid;
@ -773,12 +782,6 @@ void sleep(DWORD ticks)
yield();
}
void Task::sys$sleep(DWORD ticks)
{
ASSERT(this == current);
sleep(ticks);
}
Task* Task::kernelTask()
{
ASSERT(s_kernelTask);

View file

@ -91,7 +91,6 @@ public:
int sys$seek(int fd, int offset);
int sys$kill(pid_t pid, int sig);
int sys$geterror() { return m_error; }
void sys$sleep(DWORD ticks);
void sys$exit(int status);
int sys$spawn(const char* path);
pid_t sys$waitpid(pid_t);
@ -99,6 +98,7 @@ public:
int sys$munmap(void*, size_t size);
int sys$get_dir_entries(int fd, void*, size_t);
int sys$getcwd(char*, size_t);
int sys$sleep(unsigned seconds);
static void initialize();

Binary file not shown.

View file

@ -5,5 +5,6 @@ cp ../Userland/id mnt/bin/id
cp ../Userland/ps mnt/bin/ps
cp ../Userland/ls mnt/bin/ls
cp ../Userland/pwd mnt/bin/pwd
cp ../Userland/sleep mnt/bin/sleep
umount mnt
sync