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

plug for System.Threading? #1778

Closed
IzKuipers opened this issue May 14, 2021 · 2 comments
Closed

plug for System.Threading? #1778

IzKuipers opened this issue May 14, 2021 · 2 comments
Labels

Comments

@IzKuipers
Copy link

What is the usecase for this plug
Being able to run multiple functions at the same time, for displaying a clock, for example

Complexity of plug
I know that it might be difficult to make a plug for System.Threading, but what I also know is that it can't be impossible.

Describe alternatives you've considered
I've tried several methods for getting an interval to run for example, but all of them needed System.Threading.

Additional context
What I'm wondering is why has there been multiple issues about System.Threading, without any of them leading into a plug? These issues date all the way back to 2014, from what I can observe.


Being able to do something along the lines of this:

        public static async Task SetInterval(Action action, TimeSpan timeout)
        {
            await Task.Delay(timeout).ConfigureAwait(false);

            action();

            SetInterval(action, timeout);
        }

        public static void beforeRun() {
            SetInterval(() =>
            {
                var x = Console.CursorLeft;
                var y = Console.CursorTop;
                Console.SetCursorPosition(0, 0);
                Console.Write(RTC.Hour + ":" + RTC.Minute + ":" + RTC.Second);
                Console.SetCursorPosition(x, y);
            }, TimeSpan.FromMilliseconds(500));
        }

should not be impossible. Here is the console output I get when executing this:

Build started...
1>------ Build started: Project: TWIx86, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\5.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp2.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy.
1>C:\Users\TWI\source\repos\WebCOSv1\WebCOSv1\Core.cs(163,13,163,41): warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
1>TWIx86 -> C:\Users\TWI\source\repos\WebCOSv1\WebCOSv1\bin\Debug\netcoreapp2.0\cosmos\TWIx86.dll
1>Message: Executing IL2CPU on assembly
1>Message: Kernel Base: Cosmos.System.Kernel
1>Message: Checking target assembly: C:\Users\TWI\source\repos\WebCOSv1\WebCOSv1\bin\Debug\netcoreapp2.0\cosmos\TWIx86.dll
1>IL2CPU : error : Exception: System.Exception:
1>Native code encountered, plug required.
1>  DO NOT REPORT THIS AS A BUG.
1>  Please see http://www.gocosmos.org/docs/plugs/missing/
1>  Need plug for: System.Boolean  Microsoft.Win32.Win32Native.QueryUnbiasedInterruptTime(&System.UInt64).
1>  Called from :
1>System.Threading.TimerQueue::Int32 get_TickCount()
1>System.Threading.TimerQueue::Boolean UpdateTimer(System.Threading.TimerQueueTimer, UInt32, UInt32)
1>System.Threading.TimerQueueTimer::Boolean Change(UInt32, UInt32)
1>System.Threading.TimerQueueTimer::Void .ctor(System.Threading.TimerCallback, System.Object, UInt32, UInt32)
1>System.Threading.Timer::Void TimerSetup(System.Threading.TimerCallback, System.Object, UInt32, UInt32)
1>System.Threading.Timer::Void .ctor(System.Threading.TimerCallback, System.Object, Int32, Int32)
1>TWIx86.Core::Void startClock()
1>TWIx86.Kernel::Void BeforeRun()
1>Cosmos.System.Kernel::Void BeforeRun()
1>
1>
1>   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, String sourceItem) in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 617
1>   at Cosmos.IL2CPU.ILScanner.ScanQueue() in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 770
1>   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 264
1>   at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 200
1>IL2CPU task took 00:00:00.8074998
1>Done building project "TWIx86.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I'm by no means an expert in terms of plugs, even with my fair share of experience regarding C# and other programming languages, but, even though it is a long shot, maybe the COSMOS dev team could take it into consideration?

  • TechWorldInc
@MishaTy
Copy link
Contributor

MishaTy commented May 14, 2021

See this PR: #1610

@quajak
Copy link
Member

quajak commented May 14, 2021

Multithreading is something we wish to implement in the future, but we must first finish a bit of work before cosmos is in a good state for us to move to multithreading. Up to then, you can use your own version of the devkit and apply the pr which Misha linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants