The Pedigree Project 0.1
initialiseMultitasking.cc
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#include <config.h>
21
22#if THREADS
23
24#include "pedigree/kernel/process/PerProcessorScheduler.h"
25#include "pedigree/kernel/process/Process.h"
26#include "pedigree/kernel/process/Scheduler.h"
27#include "pedigree/kernel/process/Thread.h"
28#include "pedigree/kernel/process/initialiseMultitasking.h"
29#include "pedigree/kernel/processor/Processor.h"
30#include "pedigree/kernel/processor/ProcessorInformation.h"
31#include "pedigree/kernel/utilities/StaticString.h"
32#include "pedigree/kernel/utilities/new"
33
34void initialiseMultitasking() {
35 // Create the kernel idle process.
36 Process* pProcess = new Process();
37 pProcess->resetCounts();
38 pProcess->description() += "Kernel Process";
39 pProcess->description() += " - Processor #";
40 pProcess->description() += Processor::id();
41
42 // Create the main kernel thread.
43 Thread* pThread = new Thread(pProcess);
44 pThread->setName("core kernel thread");
45 pThread->detach();
46
47 // Initialise the scheduler.
49
50 // Initialise the per-process scheduler.
51 Processor::information().getScheduler().initialise(pThread);
52}
53
54void shutdownMultitasking() {
57}
58
59void initialiseMultitaskingPerProcessor() {
60 // Create the kernel idle process.
61 Process* pProcess = new Process();
62 pProcess->description() += "Kernel Process";
63
64 pProcess->description() += " - Processor #";
65 pProcess->description() += Processor::id();
66
67 // Create the kernel idle thread.
68 Thread* pThread = new Thread(pProcess);
69 pThread->setName("idle thread (ap)");
70 pThread->detach();
71 Processor::information().getScheduler().initialise(pThread);
72}
73
74#endif
LargeStaticString & description()
Definition Process.h:525
static ProcessorId id()
static ProcessorInformation & information()
static Scheduler & instance()
Definition Scheduler.h:96
bool initialise(Process *pKernelProcess)
Definition Scheduler.cc:113
bool detach()
Definition Thread.cc:2987