The Pedigree Project 0.1
RoundRobin.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef ROUND_ROBIN_H
21#define ROUND_ROBIN_H
22#include "pedigree/kernel/Spinlock.h"
23#include "pedigree/kernel/process/SchedulingAlgorithm.h"
24
25#include <config.h>
26
27class Thread;
28
30 public:
32 RoundRobin();
33
35 virtual ~RoundRobin();
36
37 virtual void addThread(Thread* pThread);
38
39 virtual void removeThread(Thread* pThread);
40
41 virtual Thread* getNext(Thread* pCurrentThread);
42
43 virtual bool hasReady();
44
45 virtual void threadStatusChanged(Thread* pThread);
46
47#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
49 static EXPORTED_PUBLIC bool runHostedIntrusiveQueueRegressions(Thread* pThread);
50#endif
51
52 private:
53 static bool isReady(Thread* pThread);
54
55 void enqueue(Thread* pThread);
56 void unlink(Thread* pThread);
57
58 Thread* m_pReadyQueueHeads[MAX_PRIORITIES];
59 Thread* m_pReadyQueueTails[MAX_PRIORITIES];
60#if PEDIGREE_READY_QUEUE_COUNTS
61 size_t m_ReadyQueueCounts[MAX_PRIORITIES];
62#endif
63
64 Spinlock m_Lock;
65};
66
67#endif
virtual bool hasReady()
virtual ~RoundRobin()
Definition RoundRobin.cc:41
virtual void threadStatusChanged(Thread *pThread)
virtual void addThread(Thread *pThread)
Definition RoundRobin.cc:50
virtual Thread * getNext(Thread *pCurrentThread)
virtual void removeThread(Thread *pThread)
Definition RoundRobin.cc:52