Преглед на файлове

Added a process_info abstraction

channel
Ludovic 'Archivist' Lagouardette преди 3 години
родител
ревизия
24ef19555d
променени са 4 файла, в които са добавени 22 реда и са изтрити 14 реда
  1. +2
    -2
      Makefile
  2. +16
    -8
      include/gp/pointers.hpp
  3. +1
    -1
      include/gp/vfs/process_data.hpp
  4. +3
    -3
      include/gp/vfs/system.hpp

+ 2
- 2
Makefile Целия файл

@ -1,5 +1,5 @@
CXX= clang++-10
CXXFLAGS= --std=c++20 -O0 -g -pthread -DGP_TESTS -DFUZZ_STRENGTH=100000 -DNO_BENCH=0 -pedantic \
CXX= clang++
CXXFLAGS= --std=c++2a -O0 -g -pthread -DGP_TESTS -DFUZZ_STRENGTH=100000 -DNO_BENCH=0 -pedantic \
-fprofile-instr-generate -fcoverage-mapping -Wno-unknown-attributes -fno-omit-frame-pointer \
# -fsanitize=address -fsanitize-blacklist=blacklist.txt

+ 16
- 8
include/gp/pointers.hpp Целия файл

@ -13,7 +13,7 @@ namespace gp {
gp::allocator& owner;
unique_ptr(T* _data, gp::allocator& _owner)
: data(data)
: data(_data)
, owner(_owner)
{}
@ -25,19 +25,23 @@ namespace gp {
}
public:
template<typename ...U>
unique_ptr make(gp::allocator& owner, U&&... args) {
k">static unique_ptr make(gp::allocator& owner, U&&... args) {
auto ptr = owner.allocate(sizeof(T));
return unique_ptr(new(ptr) T(gp::forward<U>(args)...), owner);
}
T& operator->() {
return o">*data;
T* operator->() {
return data;
}
T& operator*() {
return *data;
}
operator bool() {
return data != nullptr;
}
unique_ptr(unique_ptr&) = delete;
unique_ptr(unique_ptr&& oth)
@ -67,7 +71,7 @@ namespace gp {
gp::allocator& owner;
shared_ptr(T* _data, gp::allocator& _owner)
: data(data)
: data(_data)
, owner(_owner)
{}
@ -83,7 +87,7 @@ namespace gp {
}
public:
template<typename ...U>
shared_ptr make(gp::allocator& owner, U&&... args) {
k">static shared_ptr make(gp::allocator& owner, U&&... args) {
auto ptr = owner.allocate(sizeof(T));
auto shared_atomic = owner.allocate(sizeof(std::atomic_int));
refcounter = new(shared_atomic) std::atomic_int();
@ -91,14 +95,18 @@ namespace gp {
return shared_ptr(new(ptr) T(gp::forward<U>(args)...), owner);
}
T& operator->() {
return o">*data;
T* operator->() {
return data;
}
T& operator*() {
return *data;
}
operator bool() {
return data != nullptr;
}
shared_ptr(shared_ptr& oth) {
oth.refcounter->fetch_add(1, std::memory_order::acquire);

+ 1
- 1
include/gp/vfs/process_data.hpp Целия файл

@ -47,7 +47,7 @@ namespace gp {
, stack_sz(_stack_sz)
, state(gp::process_status::inactive)
, specifics(gp::buffer<char>{(char*)stack, stack_sz})
, info(_info)
, info(gp::move(_info))
{}
process_data(process_data&& v)

+ 3
- 3
include/gp/vfs/system.hpp Целия файл

@ -46,7 +46,7 @@ public:
stack_estimate = gp::buffer<char>{seed, (size_t)(gp_config::limits::process_stack*page_cnt)};
}
main_context.value = (process_data*)system_allocator.get().allocate(sizeof(process_data));
new(main_context.value) process_data(gp::function<void()>([]() -> void{}, nullopt), stack_estimate.begin().data, stack_estimate.size());
new(main_context.value) process_data(gp::function<void()>([]() -> void{}, nullopt), stack_estimate.begin().data, stack_estimate.size(), gp::unique_ptr<base_process_info>::make(system_allocator));
gp_config::assertion(main_context.value != nullptr, "failed to allocate return to main switch");
scheme.link(*this);
}
@ -57,7 +57,7 @@ public:
gp_config::assertion(stack != nullptr, "failed to allocate a stack");
process_data* created_process = (process_data*)system_allocator.get().allocate(sizeof(process_data));
gp_config::assertion(stack != nullptr, "failed to allocate a process data");
new(created_process) process_data(fn, stack, stack_sz);
new(created_process) process_data(fn, stack, stack_sz, gp::unique_ptr<base_process_info>::make(system_allocator));
topic_list::node_ptr pp = (topic_list::node_ptr)system_allocator.get().allocate(
sizeof(topic_list::node)
@ -92,7 +92,7 @@ public:
scheduler::scheduler(class system& v, size_t token)
: id(token)
, sys(v)
, main_context_data{gp::function<void()>{[](){}, v.system_allocator}, nullptr, size_t(0)}
, main_context_data{gp::function<void()>{[](){}, v.system_allocator}, nullptr, size_t(0), gp::unique_ptr<base_process_info>::make(v.system_allocator)}
, main_context()
{
main_context.value = &main_context_data;

Зареждане…
Отказ
Запис