Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Multithreading #1610

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6bef4e1
Add changes from @Og-Rok
valentinbreiz Dec 27, 2020
63b4fcc
Merge master.
valentinbreiz Jun 6, 2022
e9e32aa
Merge branch 'master' into impl-multitask
valentinbreiz Jun 6, 2022
f2716cf
Fix conflicts + Lock memory gate using new memory manager
valentinbreiz Jun 6, 2022
7f1d9f7
Merge branch 'impl-multitask' of https://github.com/CosmosOS/Cosmos i…
valentinbreiz Jun 6, 2022
d7f5026
Remove useless code
valentinbreiz Jun 6, 2022
c3540b0
Fix build
valentinbreiz Jun 6, 2022
72c6861
Merge branch 'master' into impl-multitask
valentinbreiz Jun 9, 2022
727a090
Add Threading test
valentinbreiz Jun 9, 2022
30a1b98
Update test
valentinbreiz Jun 9, 2022
aeacb31
Update sln + csproj
valentinbreiz Jun 9, 2022
52e5308
Update test
valentinbreiz Jun 9, 2022
0b263d9
Merge branch 'master' into impl-multitask
valentinbreiz Jun 19, 2022
e48cda5
Merge branch 'master' into impl-multitask
MishaTy Jan 29, 2023
ca9bf96
Merge branch 'master' into impl-multitask
valentinbreiz Dec 26, 2023
68dc3e0
🐛 Fix memory manager with multithreading
valentinbreiz Dec 26, 2023
0c5fdfd
🐛 Fix IO ports call (now static call)
valentinbreiz Dec 26, 2023
66fe85b
🐛 Fix build
valentinbreiz Dec 26, 2023
d36bfd4
🐛 Fix build (wrong mStackContext path)
valentinbreiz Dec 26, 2023
ebe5302
Merge branch 'master' into impl-multitask
valentinbreiz Jan 7, 2024
7eec507
Merge branch 'master' into impl-multitask
valentinbreiz Jan 17, 2024
8ae051b
✨ Use local APIC timer instead of PIT for scheduler
valentinbreiz Jan 17, 2024
5eb0fe7
Merge remote-tracking branch 'origin/fix/bochsClock' into impl-multitask
valentinbreiz Jan 17, 2024
fd497d1
🐛 Fix scheduler with local apic timer (now works)
valentinbreiz Jan 23, 2024
78f9e08
Merge branch 'master' into impl-multitask
valentinbreiz Jan 23, 2024
72c1436
⚡️ Set 100Hz instead of 1000Hz
valentinbreiz Jan 23, 2024
af2a785
Merge branch 'master' into impl-multitask
MishaProductions Jan 24, 2024
485c468
Merge branch 'master' into impl-multitask
valentinbreiz Jan 29, 2024
106ec6f
Merge branch 'master' into impl-multitask
zarlo Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions Test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DapperExtensions.StrongName
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Resources", "Resources", "{A45F0D24-1AF3-42BC-91A6-0262AFB1234D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThreadingTest", "Tests\Kernels\ThreadingTest\ThreadingTest.csproj", "{9491798B-DE56-4300-9A3A-025A2F7B51C2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AudioTests", "Tests\Kernels\AudioTests\AudioTests.csproj", "{8455DCAE-275E-47B3-B89B-2D9F3AB9977C}"
EndProject
Global
Expand Down Expand Up @@ -891,6 +893,18 @@ Global
{AC45D5B2-0D02-49B8-A88E-EABF34AE62B5}.TEST|Any CPU.Build.0 = Debug|Any CPU
{AC45D5B2-0D02-49B8-A88E-EABF34AE62B5}.TEST|x86.ActiveCfg = Debug|Any CPU
{AC45D5B2-0D02-49B8-A88E-EABF34AE62B5}.TEST|x86.Build.0 = Debug|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Debug|x86.ActiveCfg = Debug|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Debug|x86.Build.0 = Debug|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Release|Any CPU.Build.0 = Release|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Release|x86.ActiveCfg = Release|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.Release|x86.Build.0 = Release|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.TEST|Any CPU.ActiveCfg = TEST|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.TEST|Any CPU.Build.0 = TEST|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.TEST|x86.ActiveCfg = TEST|Any CPU
{9491798B-DE56-4300-9A3A-025A2F7B51C2}.TEST|x86.Build.0 = TEST|Any CPU
{8455DCAE-275E-47B3-B89B-2D9F3AB9977C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8455DCAE-275E-47B3-B89B-2D9F3AB9977C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8455DCAE-275E-47B3-B89B-2D9F3AB9977C}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -984,6 +998,7 @@ Global
{30D9FA9C-0B4D-40FF-8903-6B9E9C825729} = {ECEA7778-E786-4317-90B9-A2D4427CB91C}
{96855A39-A96B-4BDB-A6AE-29676DFEF637} = {29EEC029-6A2B-478A-B6E5-D63A91388ABA}
{AC45D5B2-0D02-49B8-A88E-EABF34AE62B5} = {A45F0D24-1AF3-42BC-91A6-0262AFB1234D}
{9491798B-DE56-4300-9A3A-025A2F7B51C2} = {29EEC029-6A2B-478A-B6E5-D63A91388ABA}
{8455DCAE-275E-47B3-B89B-2D9F3AB9977C} = {29EEC029-6A2B-478A-B6E5-D63A91388ABA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
1 change: 1 addition & 0 deletions Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<ProjectReference Include="..\Kernels\ProcessorTests\ProcessorTests.csproj" />
<ProjectReference Include="..\Kernels\MemoryOperationsTest\MemoryOperationsTest.csproj" />
<ProjectReference Include="..\Kernels\SimpleStructsAndArraysTest\SimpleStructsAndArraysTest.csproj" />
<ProjectReference Include="..\Kernels\ThreadingTest\ThreadingTest.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions Tests/Cosmos.TestRunner.Full/TestKernelSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static IEnumerable<Type> GetStableKernelTypes()
// This is a bit slow and works only because ring check is disabled to decide if leave it enabled
yield return typeof(MemoryOperationsTest.Kernel);
yield return typeof(ProcessorTests.Kernel);
yield return typeof(ThreadingTests.Kernel);
}
}
}
79 changes: 79 additions & 0 deletions Tests/Kernels/ThreadingTest/Kernel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using Sys = Cosmos.System;
using Cosmos.System;
using Cosmos.TestRunner;
using Console = System.Console;

namespace ThreadingTests
{
public class Kernel : Sys.Kernel
{
int variable = 0;

int variableTwo = 0;

int variableThree = 0;

protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Let's Test Threading!");
}

protected override void Run()
{
try
{
var threadOne = new Thread(ThreadOne);
var threadTwo = new Thread(ThreadTwo);

threadOne.Start();
threadTwo.Start();

Console.WriteLine("Inside Run method!");

variableThree = 3;

//Since Run is not a thread call PIT wait
System.Threading.Thread.Sleep(3000);

//Cosmos.HAL.Global.PIT.Wait(3000);

Console.WriteLine("Waited 3 second.");

Assert.AreEqual(variable, 1, "Changing global variable from thread works");

Assert.AreEqual(variableTwo, 2, "Changing global variable from second thread works");

Assert.AreEqual(variableThree, 3, "Changing global variable from main context works");

TestController.Completed();
}
catch (Exception e)
{
mDebugger.Send("Exception occurred: " + e.Message);
mDebugger.Send(e.Message);
TestController.Failed();
}
}

public void ThreadOne()
{
//Make thread WAITING
Thread.Sleep(1000);

variable = 1;

Console.WriteLine("Inside first thread!");
}

public void ThreadTwo()
{
//Make thread WAITING
Thread.Sleep(1000);

variableTwo = 2;

Console.WriteLine("Inside second thread!");
}
}
}
16 changes: 16 additions & 0 deletions Tests/Kernels/ThreadingTest/ThreadingTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<SupportsX86Intrinsics>False</SupportsX86Intrinsics>
<Configurations>Debug;Release;TEST</Configurations>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\source\Cosmos.Debug.Kernel\Cosmos.Debug.Kernel.csproj" />
<ProjectReference Include="..\..\..\source\Cosmos.System2\Cosmos.System2.csproj" />
<ProjectReference Include="..\..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj" />
<ProjectReference Include="..\Cosmos.Compiler.Tests.Bcl\Cosmos.Compiler.Tests.Bcl.csproj" />
</ItemGroup>

</Project>