[kernel] Schedule threads on other CPUs
Now that the other CPUs have been brought up, add support for scheduling tasks on them. The scheduler now maintains separate ready/blocked lists per CPU, and CPUs will attempt to balance load via periodic work stealing. Other changes as a result of this: - The device manager no longer creates a local APIC object, but instead just gathers relevant info from the APCI tables. Each CPU creates its own local APIC object. This also spurred the APIC timer calibration to become a static value, as all APICs are assumed to be symmetrical. - Fixed a bug where the scheduler was popping the current task off of its ready list, however the current task is never on the ready list (except the idle task was first set up as both current and ready). This was causing the lists to get into bad states. Now a task can only ever be current or in a ready or blocked list. - Got rid of the unused static process::s_processes list of all processes, instead of trying to synchronize it via locks. - Added spinlocks for synchronization to the scheduler and logger objects.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "kutil/bip_buffer.h"
|
||||
#include "kutil/spinlock.h"
|
||||
|
||||
namespace kutil {
|
||||
namespace log {
|
||||
@@ -111,6 +112,7 @@ private:
|
||||
uint8_t m_sequence;
|
||||
|
||||
kutil::bip_buffer m_buffer;
|
||||
kutil::spinlock m_lock;
|
||||
|
||||
static logger *s_log;
|
||||
static const char *s_level_names[static_cast<unsigned>(level::max)];
|
||||
|
||||
@@ -91,6 +91,8 @@ logger::output(level severity, area_t area, const char *fmt, va_list args)
|
||||
header->bytes +=
|
||||
vsnprintf(header->message, sizeof(buffer) - sizeof(entry), fmt, args);
|
||||
|
||||
kutil::scoped_lock lock {m_lock};
|
||||
|
||||
if (m_immediate) {
|
||||
buffer[header->bytes] = 0;
|
||||
m_immediate(area, severity, header->message);
|
||||
@@ -117,6 +119,8 @@ logger::output(level severity, area_t area, const char *fmt, va_list args)
|
||||
size_t
|
||||
logger::get_entry(void *buffer, size_t size)
|
||||
{
|
||||
kutil::scoped_lock lock {m_lock};
|
||||
|
||||
void *out;
|
||||
size_t out_size = m_buffer.get_block(&out);
|
||||
if (out_size == 0 || out == 0)
|
||||
|
||||
Reference in New Issue
Block a user