Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC primitives #25

Open
Frityet opened this issue Apr 23, 2023 · 0 comments
Open

IPC primitives #25

Frityet opened this issue Apr 23, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request Lua Scheduler

Comments

@Frityet
Copy link
Collaborator

Frityet commented Apr 23, 2023

With a proper scheduler and processes be implemented by @pitust (d82913c) IPC is needed for the userland to be able to be worked on.

The idea is something like

struct Channel {
	struct Message {
		struct Message *nullable next, *nullable previous;
		size_t length;
		byte data[];
	};

	struct Message *nonnull read_head, *nonnull write_head;
	size_t byte_count, byte_max;
	size_t message_count, message_max;
};

typedef struct PrimitiveMutex {
	struct Thread *nonnull head;
} PrimitiveMutex;

typedef struct Thread {
	char name[64];
	CPUContext ctx;
	void *stack_base;
	struct Thread *nullable next_task, *nullable previous_task;
	lua_State *nonnull lua;
	bool ready, kill;
	atomic(bool) lock;

	struct Thread *nullable next_mutex;
	PrimitiveMutex mutex;
} Thread;

int wait_for_thread(Thread *nonnull thread)
int wake_mutex(PrimitiveMutex *nonnull mtx);
int wake_all_mutexes(PrimitiveMutex *nonnull mutexes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Lua Scheduler
Projects
None yet
Development

No branches or pull requests

1 participant