/[dotgnu-pnet]/pnet/engine/process.c
ViewVC logotype

Diff of /pnet/engine/process.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.66 by rweather, Sat Oct 23 03:24:24 2004 UTC revision 1.67 by ktreichel, Thu May 5 10:16:16 2005 UTC
# Line 29  Line 29 
29  extern  "C" {  extern  "C" {
30  #endif  #endif
31    
32  int ILExecInit(unsigned long maxSize)  #ifdef IL_CONFIG_APPDOMAINS
33    /*
34     * Add an application domain to the list of application domains.
35     * param:       process = application domain to join to the linked list
36     *                      (must be not null)
37     *                      engine  = ILExecEngine to join.
38     * Returns: void
39     */
40    static IL_INLINE void ILExecProcessJoinEngine(ILExecProcess *process,
41                                                                                                    ILExecEngine *engine)
42  {  {
43  #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)          ILMutexLock(engine->processLock);
44          /* Create the global trace mutex */  
45          if ((globalTraceMutex = ILMutexCreate()) == 0)          process->engine = engine;
46            process->nextProcess = engine->firstProcess;
47            process->prevProcess = 0;
48            if(engine->firstProcess)
49          {          {
50                  return IL_EXEC_INIT_OUTOFMEMORY;                  engine->firstProcess->prevProcess = process;
51          }          }
52  #endif          engine->firstProcess = process;
         /* Initialize the thread routines */      
         ILThreadInit();  
   
         /* Initialize the global garbage collector */    
         ILGCInit(maxSize);  
53    
54          return IL_EXEC_INIT_OK;          if (!engine->defaultProcess)
55            {
56                    engine->defaultProcess = process;
57            }
58            ILMutexUnlock(engine->processLock);
59  }  }
60    
61  void ILExecDeinit()  /*
62  {         * Remove an application domain from the list of application domains.
63          /* Deinitialize the global garbage collector */   * param:       process = application domain to remove from the linked list
64          ILGCDeinit();     *                      (must be not null)
65     * Returns: void
66     */
67    static IL_INLINE void ILExecProcessDetachFromEngine(ILExecProcess *process)
68    {
69            ILExecEngine *engine = process->engine;
70            
71            ILMutexLock(engine->processLock);
72    
73          /* Deinitialize the thread routines */            /* Detach the application domain from its process */
74          ILThreadDeinit();                if(process->nextProcess)
75            {
76                    process->nextProcess->prevProcess = process->prevProcess;
77            }
78            if(process->prevProcess)
79            {
80                    process->prevProcess->nextProcess = process->nextProcess;
81            }
82            else
83            {
84                    engine->firstProcess = process->nextProcess;
85            }
86    
87  #if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)          if (engine->defaultProcess == process)
88          /* Destroy the global trace mutex */          {
89          ILMutexDestroy(globalTraceMutex);                  engine->defaultProcess = 0;
90  #endif          }
91            ILMutexUnlock(engine->processLock);
92    
93            /* reset the links */
94            process->engine = 0,
95            process->prevProcess = 0;
96            process->nextProcess = 0;
97  }  }
98    #endif
99    
100    #ifdef IL_CONFIG_APPDOMAINS
101    ILExecProcess *ILExecProcessCreate(unsigned long cachePageSize)
102    #else
103  ILExecProcess *ILExecProcessCreate(unsigned long stackSize, unsigned long cachePageSize)  ILExecProcess *ILExecProcessCreate(unsigned long stackSize, unsigned long cachePageSize)
104    #endif
105  {  {
106          ILExecProcess *process;          ILExecProcess *process;
107    
# Line 73  ILExecProcess *ILExecProcessCreate(unsig Line 113  ILExecProcess *ILExecProcessCreate(unsig
113          }          }
114          /* Initialize the fields */          /* Initialize the fields */
115          process->lock = 0;          process->lock = 0;
116          process->state = 0;          process->state = _IL_PROCESS_STATE_CREATED;
117          process->firstThread = 0;          process->firstThread = 0;
118          process->mainThread = 0;          process->mainThread = 0;
119          process->finalizerThread = 0;          process->finalizerThread = 0;
         process->stackSize = ((stackSize < IL_CONFIG_STACK_SIZE)  
                                                         ? IL_CONFIG_STACK_SIZE : stackSize);  
         process->frameStackSize = IL_CONFIG_FRAME_STACK_SIZE;  
120          process->context = 0;          process->context = 0;
121          process->metadataLock = 0;          process->metadataLock = 0;
122          process->exitStatus = 0;          process->exitStatus = 0;
# Line 113  ILExecProcess *ILExecProcessCreate(unsig Line 150  ILExecProcess *ILExecProcessCreate(unsig
150          process->imtBase = 1;          process->imtBase = 1;
151  #endif  #endif
152    
153    #ifdef IL_CONFIG_APPDOMAINS
154            process->engine = 0;
155            ILExecProcessJoinEngine(process, ILExecEngineInstance());
156    #else
157            process->stackSize = ((stackSize < IL_CONFIG_STACK_SIZE)
158                                                            ? IL_CONFIG_STACK_SIZE : stackSize);
159            process->frameStackSize = IL_CONFIG_FRAME_STACK_SIZE;
160    #endif
161          /* Initialize the image loading context */          /* Initialize the image loading context */
162          if((process->context = ILContextCreate()) == 0)          if((process->context = ILContextCreate()) == 0)
163          {          {
# Line 261  void ILExecProcessDestroy(ILExecProcess Line 306  void ILExecProcessDestroy(ILExecProcess
306                          /* If the main thread is the finalizer thread then                          /* If the main thread is the finalizer thread then
307                             we have to zero the memory of the CVM stack so that                             we have to zero the memory of the CVM stack so that
308                             stray pointers are erased */                             stray pointers are erased */
309    #ifdef IL_CONFIG_APPDOMAINS
310                            ILMemZero(process->mainThread->stackBase, process->engine->stackSize);
311                            ILMemZero(process->mainThread->frameStack, process->engine->frameStackSize);
312    #else
313                          ILMemZero(process->mainThread->stackBase, process->stackSize);                          ILMemZero(process->mainThread->stackBase, process->stackSize);
314                          ILMemZero(process->mainThread->frameStack, process->frameStackSize);                          ILMemZero(process->mainThread->frameStack, process->frameStackSize);
315    #endif
316                  }                  }
317                  else                  else
318                  {                  {
# Line 479  void ILExecProcessDestroy(ILExecProcess Line 529  void ILExecProcessDestroy(ILExecProcess
529                  ILMutexDestroy(process->lock);                  ILMutexDestroy(process->lock);
530          }          }
531    
532    #ifdef IL_CONFIG_APPDOMAINS
533    
534            if (process->engine)
535            {
536                    ILExecProcessDetachFromEngine(process);
537            }
538    #endif
539    
540          /* Free the process block itself */          /* Free the process block itself */
541          ILGCFreePersistent(process);          ILGCFreePersistent(process);
542    
# Line 785  ILObject *ILExecProcessSetCommandLine(IL Line 843  ILObject *ILExecProcessSetCommandLine(IL
843          return mainArgs;          return mainArgs;
844  }  }
845    
846    #ifndef IL_CONFIG_APPDOMAINS
847  int ILExecProcessAddInternalCallTable(ILExecProcess* process,  int ILExecProcessAddInternalCallTable(ILExecProcess* process,
848                                          const ILEngineInternalClassInfo* internalClassTable,                                          const ILEngineInternalClassInfo* internalClassTable,
849                                          int tableSize)                                          int tableSize)
# Line 810  int ILExecProcessAddInternalCallTable(IL Line 869  int ILExecProcessAddInternalCallTable(IL
869          tmp->next=NULL;          tmp->next=NULL;
870          return 1;          return 1;
871  }  }
872    #endif
873    
874  void ILExecProcessSetCoderFlags(ILExecProcess *process,int flags)  void ILExecProcessSetCoderFlags(ILExecProcess *process,int flags)
875  {  {

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.67

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26