Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module main;
- import tango.core.Exception;
- import tango.io.Stdout;
- import tango.core.Memory;
- import tango.stdc.stdlib;
- import tango.util.log.Log;
- import tango.sys.Process;
- import tango.core.Thread;
- import tango.stdc.posix.unistd;
- import ocean.util.log.Trace;
- void main()
- {
- void doFork ( )
- {
- while (true)
- {
- Trace.formatln("Suspending");
- thread_suspendAll();
- if ( fork() != 0 )
- {
- Trace.formatln("Forked");
- thread_resumeAll();
- Trace.formatln("Resuming");
- }
- else
- {
- Trace.formatln("Forked-Child, Exiting");
- exit(1);
- }
- }
- }
- void doMalloc ( )
- {
- while ( true)
- {
- Trace.formatln("Malloc, allocating");
- auto mem = malloc(10000);
- Trace.formatln("Malloc, freeing");
- free(mem);
- }
- }
- auto fork = new Thread(&doFork);
- auto malloc = new Thread(&doMalloc);
- malloc.start;
- fork.start;
- }
Add Comment
Please, Sign In to add comment