3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #ifndef _XBT_CONTEXT_PRIVATE_H
9 #define _XBT_CONTEXT_PRIVATE_H
12 #include "xbt/sysdep.h"
14 #include "xbt/dynar.h" /* void_f_pvoid_t */
15 #include "portable.h" /* loads context system definitions */
17 #include "xbt/context.h"
20 #ifdef CONTEXT_THREADS
21 # include "xbt/xbt_os_thread.h"
23 # include "ucontext_stack.h" /* loads context system definitions */
24 # include <ucontext.h>
25 # define STACK_SIZE 128*1024 /* Lower this if you want to reduce the memory consumption */
26 #endif /* not CONTEXT_THREADS */
29 typedef struct s_xbt_context {
30 s_xbt_swag_hookup_t hookup;
33 /* Declaration of the thread running the process */
34 #ifdef JAVA_SIMGRID /* come first because other ones are defined too */
35 jobject jprocess; /* the java process instance */
36 JNIEnv* jenv; /* jni interface pointer for this thread */
37 ex_ctx_t *exception; /* exception container -- only in ucontext&java, os_threads deals with it for us otherwise */
39 # ifdef CONTEXT_THREADS
40 xbt_os_thread_t thread; /* a plain dumb thread (portable to posix or windows) */
41 xbt_os_sem_t begin; /* this semaphore is used to schedule/unschedule the process */
42 xbt_os_sem_t end; /* this semaphore is used to schedule/unschedule the process */
44 ucontext_t uc; /* the thread that execute the code */
45 char stack[STACK_SIZE];
46 struct s_xbt_context *save;
47 ex_ctx_t *exception; /* exception container -- only in ucontext&java, os_threads deals with it for us otherwise */
48 # endif /* CONTEXT_THREADS */
49 #endif /* JAVA_SIMGRID */
52 xbt_main_func_t code; /* the scheduled fonction */
56 /* Init/exit functions */
57 void_f_pvoid_t startup_func;
59 void_f_pvoid_t cleanup_func;
61 int iwannadie; /* Set to true by the context when it wants to commit suicide */
65 #endif /* !_XBT_CONTEXT_PRIVATE_H */