Skip to content

Commit

Permalink
VM: main thread handling changed
Browse files Browse the repository at this point in the history
  • Loading branch information
koder77 committed Jan 9, 2022
1 parent adc874d commit 2934bce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
L1VM - (1.4.3)
VM: main function now uses wait loop thread 1 on macOS only.
On macOS the main program will run in thread 0. This is needed to run the SDL module.
It can only be run from main program!
The other OS will run the VM bytecode in thread 1.

-- Stefan Pietzonke <jay-t@gmx.net> Sun 09 Jan 2021 16:45 +0100

L1VM - (1.4.2)

JIT-compiler now sets a return code for run function and exits the program on error!
Expand Down
2 changes: 1 addition & 1 deletion include/global.h
Expand Up @@ -104,7 +104,7 @@
// info strings:
#define COPYRIGHT_STR " (C) 2017-2022 Stefan Pietzonke"

#define VM_VERSION_STR "1.4.2" // version number
#define VM_VERSION_STR "1.4.3" // version number

// no user defined definitions below this section! ============================

Expand Down
10 changes: 10 additions & 0 deletions vm/main.c
Expand Up @@ -3126,6 +3126,8 @@ int main (int ac, char *av[])
threaddata[new_cpu].sp_bottom_thread = threaddata[new_cpu].sp_bottom + (new_cpu * stack_size);
threaddata[new_cpu].ep_startpos = 16;

// on macOS use wait loop thread, because the SDL module must be run from main thread!!!
#if __MACH__
new_cpu++;
if (pthread_create (&id, NULL, (void *) run_main_loop_thread, (void *) new_cpu) != 0)
{
Expand All @@ -3137,6 +3139,14 @@ int main (int ac, char *av[])

// start main thread
run (0);
#else
if (pthread_create (&id, NULL, (void *) run, (void *) new_cpu) != 0)
{
printf ("ERROR: can't start main thread!\n");
cleanup ();
exit (1);
}
#endif

pthread_join (id, NULL);
cleanup ();
Expand Down

0 comments on commit 2934bce

Please sign in to comment.