make globals static
Only use the malloc mutex if the os is already running.

This prevents lockups if you use malloc before you start the os with os_run().