Skip to content

IPC primitives #25

Description

@Frityet

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions