#ifndef PROCESS_H
#define PROCESS_H

#include "memory.h"
#include "fileobj.h"

int num_processes;

struct context {
	unsigned int esp; // first for asm easyness
	pd_t *pd;
	unsigned int valloc_addr;
	unsigned int heap_top;
};

extern struct context *cur_cx;
extern struct context kernel_cx;

struct process_item  {
	unsigned short pid;
	unsigned short owner;
	short timeslice;
	short timeleft;
	
	unsigned int entry;
	struct context cx;
	
	struct process_item *next;
	struct process_item *prev;

	struct process *proc;
};

struct process {
	struct file_object *fd_table[10];
	fd_t n_fds;
	/* stuff like FDs */
};

extern struct process_item *cur_proc;
extern struct process_item *first_proc;

void internal_init_process(struct process_item *proc);
void process_init(struct process_item *proc, unsigned int entry);
void sys_process_start(struct process_item *proc);

#endif /* PROCESS_H */
