1 /* -----------------------------------------------------------------------------
2 * $Id: Main.c,v 1.11 1999/09/16 08:29:01 sof Exp $
4 * (c) The GHC Team 1998-1999
6 * Main function for a standalone Haskell program.
8 * ---------------------------------------------------------------------------*/
10 #define COMPILING_RTS_MAIN
16 #include "Schedule.h" /* for MainTSO */
20 #include "Printer.h" /* for printing */
24 #include "Assembler.h"
38 /* Hack: we assume that we're building a batch-mode system unless
41 # ifndef INTERPRETER /* Hack */
42 int main(int argc, char *argv[])
44 SchedulerStatus status;
45 startupHaskell(argc,argv);
48 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
49 RtsFlags.GcFlags.initialStkSize),
50 (StgClosure *)&mainIO_closure);
51 status = schedule(MainTSO,NULL);
53 if (IAmMainThread == rtsTrue) {
54 /*Just to show we're alive */
55 fprintf(stderr, "Main Thread Started ...\n");
57 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
58 RtsFlags.GcFlags.initialStkSize),
59 (StgClosure *)&mainIO_closure);
60 status = schedule(MainTSO,NULL);
62 WaitForPEOp(PP_FINISH,SysManTask);
68 barf("Scheduler stopped, all threads blocked");
71 barf("No threads to run! Deadlock?");
73 belch("%s: warning: main thread killed", prog_argv[0]);
78 shutdownHaskellAndExit(EXIT_SUCCESS);
80 # endif /* BATCH_MODE */