BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / blob / 88d672affcc1b9e1de646809e06bca1737f94f25 / include / nucleus / task.h

// Related

Nucleus

Barry Files namespace f0dcd54 (3 years, 3 months ago)
#ifndef _NUCLEUS_TASK_H
#define _NUCLEUS_TASK_H

#include <stdint.h>
#include <sys/types.h>
#include <nucleus/cpu.h>
#include <nucleus/object.h>
#include <nucleus/memory.h>
#include <nucleus/vfs.h>

typedef struct Task Task;

/* Task priorities */
enum Priority {
	NONE,
	LOWEST,
	LOW,
	NORMAL,
	HIGH,
	HIGHEST,
};

/* Task states */
enum State {
	RUNNING,
	READY,
	TERMINATED,
};

/* Structure for a Task */
struct Task {
	Object obj;
	pid_t tid, tgid;
	uid_t uid, euid, suid;
	gid_t gid, egid, sgid;
	enum Priority priority;
	enum State state;

	uintptr_t esp, ebp, eip;
	page_dir_t pageDir;

	/* Namespaces */
	FileSystem *fs;
	Files *files;
};

extern ObjectType taskType;

extern Task *currentTask[];
#define current currentTask[CPUID]

/* Check if super-user */
static inline int
super_user(void)
{
	return (current->euid == 0);
}

void init_tasking(void);
void schedule(void);
pid_t clone(int flags);

#endif