Browse Source

scaffolding of a system for async

channel
Ludovic 'Archivist' Lagouardette 3 years ago
parent
commit
f366a7723c
3 changed files with 63 additions and 3 deletions
  1. +50
    -1
      include/gp/vfs/platforms/gcc-x86_64.hpp
  2. +0
    -2
      include/gp/vfs/process_data.hpp
  3. +13
    -0
      include/gp/vfs/scheduler.hpp

+ 50
- 1
include/gp/vfs/platforms/gcc-x86_64.hpp View File

@ -1,9 +1,58 @@
#pragma once
#include <cstdint>
#define no_inline_decl(a) [[gnu::noinline]] a
namespace gp{
namespace specifics {
struct platform_data {
uint64_t rbx, r12, r13, r14, r15;
void* stack_ptr;
void* base_ptr;
void pull() __attribute__((always_inline))
{
__asm__ __volatile__(
"movq %%rsp, %0\n"
"movq %%rbp, %1\n"
"movq %%rbx, %2\n"
"movq %%r12, %3\n"
"movq %%r13, %4\n"
"movq %%r14, %5\n"
"movq %%r15, %6\n"
: "=m"(stack_ptr)
, "=m"(base_ptr)
, "=m"(rbx)
, "=m"(r12)
, "=m"(r13)
, "=m"(r14)
, "=m"(r15));
}
void* push(void* location) __attribute__((always_inline))
{
void* tmp = static_cast<char*>(stack_ptr) - sizeof(void*);
*static_cast<void**>(tmp) = location;
__asm__ __volatile__(
"movq %1, %%rsp\n"
"movq %2, %%rbp\n"
"movq %3, %%r12\n"
"movq %4, %%r13\n"
"movq %5, %%r14\n"
"movq %6, %%r15\n"
"popq %0\n"
: "+r"(location)
: "m"(tmp)
, "m"(base_ptr)
, "m"(r12)
, "m"(r13)
, "m"(r14)
, "m"(r15)
: "memory");
return location;
}
};
}
}

+ 0
- 2
include/gp/vfs/process_data.hpp View File

@ -19,8 +19,6 @@ namespace gp {
struct process_data{
[[no_unique_address]] gp::specifics::platform_data specifics;
void* stack_ptr;
void* base_ptr;
gp::function<void()> fn;
gp::indexed_array<gp::file_description*, gp_config::limits::max_fd_per_process> fds;
};

+ 13
- 0
include/gp/vfs/scheduler.hpp View File

@ -7,8 +7,21 @@ namespace gp{
class scheduler {
gp::indexed_array<gp::process_data*, gp_config::limits::max_processes> processes;
gp::specifics::platform_data root;
size_t current;
no_inline_decl(
void yield_impl(bool terminate)
) {
}
public:
[[noreturn]] void run();
void yield(){
yield_impl(false);
}
};
}

Loading…
Cancel
Save