Compare commits

..

No commits in common. "01564cb9058aa994422cf06d06cd459709a60da4" and "a9d3bdba6f412cf1a3b4f0515f922d164cbb8585" have entirely different histories.

11 changed files with 15 additions and 58 deletions

@ -64,7 +64,7 @@ int main()
printf("Welcome to Luna!\n");
printf("Running as PID %ld, PPID %ld\n\n", getpid(), getppid());
printf("Running as PID %ld\n\n", getpid());
sleep(1);
@ -163,7 +163,7 @@ int main()
if (child == 0)
{
msleep(500);
printf("I am the child (PID %ld), my parent is PID %ld!!\n", getpid(), getppid());
printf("I am the child, who is my parent?\n");
execv("/bin/sym", NULL);
perror("execv");
return 1;

@ -7,7 +7,7 @@
#define SYS_sleep 2
#define SYS_write 3
#define SYS_paint 4
#define SYS_getprocid 5
#define SYS_getpid 5
#define SYS_mmap 6
#define SYS_munmap 7
#define SYS_open 8
@ -33,7 +33,7 @@ void sys_yield(Context* context);
void sys_sleep(Context* context, uint64_t ms);
void sys_write(Context* context, int fd, size_t size, const char* addr);
void sys_paint(Context* context, uint64_t x, uint64_t y, uint64_t w, uint64_t h, uint64_t col);
void sys_getprocid(Context* context, int field);
void sys_getpid(Context* context);
void sys_mmap(Context* context, void* address, size_t size, int prot);
void sys_munmap(Context* context, void* address, size_t size);
void sys_open(Context* context, const char* filename, int flags);

@ -16,7 +16,7 @@ void Syscall::entry(Context* context)
case SYS_sleep: sys_sleep(context, context->rdi); break;
case SYS_write: sys_write(context, (int)context->rdi, context->rsi, (const char*)context->rdx); break;
case SYS_paint: sys_paint(context, context->rdi, context->rsi, context->rdx, context->r10, context->r8); break;
case SYS_getprocid: sys_getprocid(context, (int)context->rdi); break;
case SYS_getpid: sys_getpid(context); break;
case SYS_mmap: sys_mmap(context, (void*)context->rdi, context->rsi, (int)context->rdx); break;
case SYS_munmap: sys_munmap(context, (void*)context->rdi, context->rsi); break;
case SYS_open: sys_open(context, (const char*)context->rdi, (int)context->rsi); break;

@ -1,24 +0,0 @@
#include "errno.h"
#include "thread/Scheduler.h"
#define ID_PID 0
#define ID_PPID 1
void sys_getprocid(Context* context, int field)
{
if (field == ID_PID)
{
context->rax = Scheduler::current_task()->id;
return;
}
else if (field == ID_PPID)
{
context->rax = Scheduler::current_task()->ppid;
return;
}
else
{
context->rax = -EINVAL;
return;
}
}

@ -18,4 +18,9 @@ void sys_sleep(Context* context, uint64_t ms)
task->task_sleep = ms;
task->state = task->Sleeping;
Scheduler::task_yield(context);
}
void sys_getpid(Context* context)
{
context->rax = Scheduler::current_task()->id;
}

@ -1,7 +0,0 @@
#ifndef _BITS_GETPROCID_H
#define _BITS_GETPROCID_H
#define ID_PID 0
#define ID_PPID 1
#endif

@ -1,7 +1,6 @@
#ifndef _LUNA_H
#define _LUNA_H
#include <bits/getprocid.h>
#include <bits/macros.h>
#include <sys/types.h>
@ -10,9 +9,6 @@ extern "C"
{
#endif
/* Returns a numeric identifier associated with the current process, depending on field. */
long getprocid(int field);
/* Sleeps for ms milliseconds. */
unsigned int msleep(unsigned int ms);

@ -6,7 +6,7 @@
#define SYS_sleep 2
#define SYS_write 3
#define SYS_paint 4
#define SYS_getprocid 5
#define SYS_getpid 5
#define SYS_mmap 6
#define SYS_munmap 7
#define SYS_open 8

@ -27,12 +27,9 @@ extern "C"
* the parent. */
pid_t fork(void);
/* Returns the current process' process ID. */
/* Returns the current process's process ID. */
pid_t getpid(void);
/* Returns the current process' parent's process ID. */
pid_t getppid(void);
/* Terminates the program with the status code status. */
__lc_noreturn void _exit(int status);

@ -7,11 +7,6 @@
extern "C"
{
long getprocid(int field)
{
return syscall(SYS_getprocid, field);
}
unsigned int msleep(unsigned int ms)
{
return (unsigned int)syscall(SYS_sleep, ms);

@ -27,12 +27,7 @@ extern "C"
pid_t getpid(void)
{
return getprocid(ID_PID);
}
pid_t getppid(void)
{
return getprocid(ID_PPID);
return syscall(SYS_getpid);
}
long syscall(long number, ...)
@ -45,9 +40,9 @@ extern "C"
{
case SYS_clock:
case SYS_yield:
case SYS_fork: result = __luna_syscall0(number); break;
case SYS_fork:
case SYS_getpid: result = __luna_syscall0(number); break;
case SYS_exit:
case SYS_getprocid:
case SYS_close:
case SYS_exec:
case SYS_mkdir: