Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison VMS.c @ 30:c8823e0bb2b4
Started adding own version of malloc and free
Just in case they're using TLS and causing the issues
| author | Me |
|---|---|
| date | Mon, 09 Aug 2010 02:24:31 -0700 |
| parents | 0e008278fe3c |
| children | e69579a0e797 65e5918731b8 |
comparison
equal
deleted
inserted
replaced
| 11:d21d939b862a | 12:e65c232fa04b |
|---|---|
| 98 //First core loop to start up gets this, which will schedule seed Pr | 98 //First core loop to start up gets this, which will schedule seed Pr |
| 99 //TODO: debug: check address of masterVirtPr | 99 //TODO: debug: check address of masterVirtPr |
| 100 writeVMSQ( masterEnv->masterVirtPr, workQ ); | 100 writeVMSQ( masterEnv->masterVirtPr, workQ ); |
| 101 | 101 |
| 102 numProcrsCreated = 1; //global counter for debugging | 102 numProcrsCreated = 1; //global counter for debugging |
| 103 } | 103 |
| 104 //==================== malloc substitute ======================== | |
| 105 // | |
| 106 //Testing whether malloc is using thread-local storage and therefore | |
| 107 // causing unreliable behavior. | |
| 108 //Just allocate a massive chunk of memory and roll own malloc/free and | |
| 109 // make app use VMS__malloc_to, which will suspend and perform malloc | |
| 110 // in the master, taking from this massive chunk. | |
| 111 | |
| 112 // initFreeList(); | |
| 113 } | |
| 114 | |
| 115 /* | |
| 116 void | |
| 117 initMasterMalloc() | |
| 118 { | |
| 119 _VMSMasterEnv->mallocChunk = malloc( MASSIVE_MALLOC_SIZE ); | |
| 120 | |
| 121 //The free-list element is the first several locations of an | |
| 122 // allocated chunk -- the address given to the application is pre- | |
| 123 // pended with both the ownership structure and the free-list struc. | |
| 124 //So, write the values of these into the first locations of | |
| 125 // mallocChunk -- which marks it as free & puts in its size. | |
| 126 listElem = (FreeListElem *)_VMSMasterEnv->mallocChunk; | |
| 127 listElem->size = MASSIVE_MALLOC_SIZE - NUM_PREPEND_BYTES | |
| 128 listElem->next = NULL; | |
| 129 } | |
| 130 | |
| 131 void | |
| 132 dissipateMasterMalloc() | |
| 133 { | |
| 134 //Just foo code -- to get going -- doing as if free list were link-list | |
| 135 currElem = _VMSMasterEnv->freeList; | |
| 136 while( currElem != NULL ) | |
| 137 { | |
| 138 nextElem = currElem->next; | |
| 139 masterFree( currElem ); | |
| 140 currElem = nextElem; | |
| 141 } | |
| 142 free( _VMSMasterEnv->freeList ); | |
| 143 } | |
| 144 */ | |
| 104 | 145 |
| 105 void | 146 void |
| 106 create_sched_slots( MasterEnv *masterEnv ) | 147 create_sched_slots( MasterEnv *masterEnv ) |
| 107 { SchedSlot **schedSlots, **filledSlots; | 148 { SchedSlot **schedSlots, **filledSlots; |
| 108 int i; | 149 int i; |
| 549 /*Am trying to be cute, avoiding IF statement in coreLoop that checks for | 590 /*Am trying to be cute, avoiding IF statement in coreLoop that checks for |
| 550 * a special shutdown procr. Ended up with extra-complex shutdown sequence. | 591 * a special shutdown procr. Ended up with extra-complex shutdown sequence. |
| 551 *This function has the sole purpose of setting the stack and framePtr | 592 *This function has the sole purpose of setting the stack and framePtr |
| 552 * to the coreLoop's stack and framePtr.. it does that then jumps to the | 593 * to the coreLoop's stack and framePtr.. it does that then jumps to the |
| 553 * core loop's shutdown point -- might be able to just call Pthread_exit | 594 * core loop's shutdown point -- might be able to just call Pthread_exit |
| 554 * from here, but going back to the pthread's stack and setting everything | 595 * from here, but am going back to the pthread's stack and setting everything |
| 555 * up just as if it never jumped out, before calling pthread_exit. | 596 * up just as if it never jumped out, before calling pthread_exit. |
| 556 *The end-point of core loop will free the stack and so forth of the | 597 *The end-point of core loop will free the stack and so forth of the |
| 557 * processor that animates this function, (this fn is transfering the | 598 * processor that animates this function, (this fn is transfering the |
| 558 * animator of the AppVP that is in turn animating this function over | 599 * animator of the AppVP that is in turn animating this function over |
| 559 * to core loop function -- note that this slices out a level of virtual | 600 * to core loop function -- note that this slices out a level of virtual |
| 578 ); | 619 ); |
| 579 } | 620 } |
| 580 | 621 |
| 581 | 622 |
| 582 | 623 |
| 583 /*This is called has to free anything allocated during VMS_init, and any other alloc'd | 624 /*This is called after the threads have shut down and control as returned |
| 625 * to the semantic layer, in the entry point function in the main thread. | |
| 626 * It has to free anything allocated during VMS_init, and any other alloc'd | |
| 584 * locations that might be left over. | 627 * locations that might be left over. |
| 585 */ | 628 */ |
| 586 void | 629 void |
| 587 VMS__cleanup_after_shutdown() | 630 VMS__cleanup_after_shutdown() |
| 588 { int i; | 631 { int i; |
