Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
This change concerne the usage of the semaphore object instead the variable condition...
[simgrid.git] / src / xbt / context_private.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
4
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. */
7
8 #ifndef _XBT_CONTEXT_PRIVATE_H
9 #define _XBT_CONTEXT_PRIVATE_H
10
11
12 #include "xbt/sysdep.h"
13 #include "xbt/swag.h"
14 #include "xbt/dynar.h" /* void_f_pvoid_t */
15 #include "portable.h"  /* loads context system definitions */
16
17 #include "xbt/context.h"
18 #include "xbt/ex.h"
19
20 #ifdef CONTEXT_THREADS
21 #  include "xbt/xbt_os_thread.h"
22 #else
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 */
27
28
29 typedef struct s_xbt_context {
30         s_xbt_swag_hookup_t hookup;
31         char *name;
32
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 */
38 #else   
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 */
43 # else
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 */
50
51         /* What to run */
52         xbt_main_func_t code;   /* the scheduled fonction           */
53         int argc;
54         char **argv;
55    
56         /* Init/exit functions */   
57         void_f_pvoid_t startup_func;
58         void *startup_arg;
59         void_f_pvoid_t cleanup_func;
60         void *cleanup_arg;
61         int iwannadie;                  /* Set to true by the context when it wants to commit suicide */
62 } s_xbt_context_t;
63
64
65 #endif  /* !_XBT_CONTEXT_PRIVATE_H */