Compare commits

..

No commits in common. "7ab80014e1d659f4577700021112265ccbe4e3a1" and "20cffdb66c76cc3373675ada152cf9e021cd0563" have entirely different histories.

7 changed files with 9 additions and 30 deletions

View File

@ -11,6 +11,7 @@ CFLAGS := -Wall -Wextra -Werror -Os
$(APPS_BIN)/%: $(APPS_SRC)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ $^
$(STRIP) $@
build: $(REAL_APPS)

View File

@ -141,13 +141,9 @@ int main()
fclose(new_stderr);
pid_t child = fork();
if (child == 0)
{
msleep(500);
printf("I am the child, who is my parent?\n");
}
else { printf("My child is %ld!", child); }
execv("/bin/sym", NULL);
return 0;
perror("execv"); // If we're here, execv failed
return 1;
}

View File

@ -32,23 +32,16 @@ void sys_fork(Context* context) // FIXME: Even though both processes's address s
size_t stack_bytes = get_top_of_stack(parent->allocated_stack, TASK_PAGES_IN_STACK) - parent->regs.rsp;
child->regs.rsp = get_top_of_stack(child->allocated_stack, TASK_PAGES_IN_STACK) - stack_bytes;
child->regs.rsp -= stack_bytes;
memcpy((void*)child->regs.rsp, (void*)parent->regs.rsp, stack_bytes);
child->regs.rsp += sizeof(uintptr_t) * 2; // I don't know why this is...
child->address_space = parent->address_space.clone();
child->regs.rax = 0;
context->rax = child->id;
child->state = child->Running;
kinfoln("fork(): parent RIP %lx, child RIP %lx, parent RSP %lx, child RSP %lx", parent->regs.rip, child->regs.rip,
parent->regs.rsp, child->regs.rsp);
kinfoln("fork(): forked parent %ld into child %ld", parent->id, child->id);
kinfoln("fork(): forked parent %d into child %d", parent->id, child->id);
return;
}

View File

@ -1,6 +1,5 @@
#include "trace/StackTracer.h"
#include "memory/Memory.h"
#include "memory/VMM.h"
#include "std/stdio.h"
#include "trace/Resolve.h"
@ -21,11 +20,6 @@ typedef struct stackframe
void StackTracer::trace()
{
if (!VMM::is_using_kernel_address_space())
{
VMM::switch_back_to_kernel_address_space();
VMM::apply_address_space();
}
stackframe* frame = (stackframe*)m_base_pointer;
while (frame && frame->instruction)
{
@ -33,7 +27,6 @@ void StackTracer::trace()
get_symbol_name(frame->instruction, symbol_name, sizeof(symbol_name));
printf("%lx: %s\n", frame->instruction, symbol_name);
frame = frame->next;
if (VMM::get_physical((uint64_t)frame) == (uint64_t)-1) return;
}
}

View File

@ -17,7 +17,6 @@
#define SYS_fcntl 13
#define SYS_mprotect 14
#define SYS_clock 15
#define SYS_fork 16
#ifndef __want_syscalls
#ifdef __cplusplus

View File

@ -22,8 +22,7 @@ extern "C"
int execve(const char*, char* const[], char* const[]);
/* Not implemented. */
int execvp(const char*, char* const[]);
/* Creates an identical copy of the current process and returns its process ID. */
/* Not implemented. */
pid_t fork(void);
/* Terminates the program with the status code status. */

View File

@ -19,10 +19,9 @@ extern "C"
{
NOT_IMPLEMENTED("execvp");
}
pid_t fork(void)
{
return syscall(SYS_fork);
NOT_IMPLEMENTED("fork");
}
long syscall(long number, ...)
@ -35,7 +34,6 @@ extern "C"
{
case SYS_clock:
case SYS_yield:
case SYS_fork:
case SYS_gettid: result = __luna_syscall0(number); break;
case SYS_exit:
case SYS_close: