summaryrefslogtreecommitdiffstats
path: root/src/include/kernel/taskmgr.H
blob: 82aab7da1d447f6c7ae8b0b698bf03bf18963a91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef __KERNEL_TASKMGR_H
#define __KENREL_TASKMGR_H

#include <kernel/types.h>
#include <util/lockfree/counter.H>
#include <kernel/vmmmgr.H>

class TaskManager
{
    public:
	static task_t* getCurrentTask();
	static void setCurrentTask(task_t* t);

	typedef void(*task_fn_t)(void*);
	static task_t* createTask(task_fn_t, void*);

	friend class CpuManager;
    protected:
	TaskManager();
	~TaskManager() {};

	static task_t* createIdleTask();

    private:
	tid_t getNextTid()
	    { return iv_nextTid.next(); };
	Util::Lockfree::Counter<tid_t> iv_nextTid;

	static void idleTaskLoop(void*);
	task_t* _createIdleTask();
	task_t* _createTask(task_fn_t, void*, bool);
};

#endif
OpenPOWER on IntegriCloud