Cosmos/source/Cosmos.Core_Plugs/System/Threading/ThreadImpl.cs
Og-Rok 2d5f637a91 Softwaare Multitasking
Working context switching but far from stable. Changes needed to be made
to the internals of cosmos to include mutex's in vital components (Heap,
Thread Manager, ect). Context switching currently only switches the
general registers and does not switch the MMX context, however this will
be added in the future. Also when a thread currently dies it takes the
whole system down, patches to the IDT handlers needed to be made to
prevent system lockup in the future
2018-04-04 01:22:52 +01:00

42 lines
1.4 KiB
C#

using System.Threading;
using IL2CPU.API.Attribs;
using Console = System.Console;
namespace Cosmos.Core_Plugs.System.Threading
{
[Plug(Target = typeof(Thread))]
public static class ThreadImpl
{
public static Thread GetCurrentThreadNative()
{
return null;
}
public static void MemoryBarrier()
{
}
public static void Ctor(ThreadStart aThis, ThreadStart aEntry)
{
Console.WriteLine("Thread started");
}
// public static void SleepInternal(int ms)
// {
// // Implementation of http://referencesource.microsoft.com/#mscorlib/system/threading/thread.cs,6a577476abf2f437,references
// // see https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx for more details
// if ((ms > 0) && (ms != Timeout.Infinite))
// {
// double fac = ProcessorInformation.GetCycleRate() / 1000d;
// double ticks = ms / 1000d * Stopwatch.Frequency + ProcessorInformation.GetCycleCount() * fac;
// while (ticks < ProcessorInformation.GetCycleCount() * fac)
// new Action(() => { }).Invoke(); // execute an empty operation
// }
// else if (ms < 0)
// throw new ThreadInterruptedException();
// }
}
}