Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison VMS.c @ 77:fe5ec83f1baf
separated hardware dependent code
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 22 Jun 2011 16:12:27 +0200 |
| parents | 9ddbb071142d |
| children | 521c75d64cef |
comparison
equal
deleted
inserted
replaced
| 40:d7ea8d2cfe8f | 41:ca7ff8cf081a |
|---|---|
| 10 #include <malloc.h> | 10 #include <malloc.h> |
| 11 #include <inttypes.h> | 11 #include <inttypes.h> |
| 12 #include <sys/time.h> | 12 #include <sys/time.h> |
| 13 | 13 |
| 14 #include "VMS.h" | 14 #include "VMS.h" |
| 15 #include "SwitchAnimators.h" | 15 #include "ProcrContext.h" |
| 16 #include "Queue_impl/BlockingQueue.h" | 16 #include "Queue_impl/BlockingQueue.h" |
| 17 #include "Histogram/Histogram.h" | 17 #include "Histogram/Histogram.h" |
| 18 | 18 |
| 19 | 19 |
| 20 #define thdAttrs NULL | 20 #define thdAttrs NULL |
| 279 coreLoop_Seq( NULL ); | 279 coreLoop_Seq( NULL ); |
| 280 flushRegisters(); | 280 flushRegisters(); |
| 281 | 281 |
| 282 } | 282 } |
| 283 #endif | 283 #endif |
| 284 | |
| 285 /*Create stack, then create __cdecl structure on it and put initialData and | |
| 286 * pointer to the new structure instance into the parameter positions on | |
| 287 * the stack | |
| 288 *Then put function pointer into nextInstrPt -- the stack is setup in std | |
| 289 * call structure, so jumping to function ptr is same as a GCC generated | |
| 290 * function call | |
| 291 *No need to save registers on old stack frame, because there's no old | |
| 292 * animator state to return to -- | |
| 293 * | |
| 294 */ | |
| 295 inline VirtProcr * | |
| 296 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr, | |
| 297 void *initialData, void *stackLocs ) | |
| 298 { | |
| 299 void *stackPtr; | |
| 300 | |
| 301 newPr->startOfStack = stackLocs; | |
| 302 newPr->procrID = _VMSMasterEnv->numProcrsCreated++; | |
| 303 newPr->initialData = initialData; | |
| 304 newPr->requests = NULL; | |
| 305 newPr->schedSlot = NULL; | |
| 306 | |
| 307 /* | |
| 308 * Hardware dependent part | |
| 309 */ | |
| 310 //instead of calling the function directly, call a wrapper function to fetch | |
| 311 //arguments from stack | |
| 312 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn; | |
| 313 | |
| 314 //fnPtr takes two params -- void *initData & void *animProcr | |
| 315 //alloc stack locations, make stackPtr be the highest addr minus room | |
| 316 // for 2 params + return addr. Return addr (NULL) is in loc pointed to | |
| 317 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above | |
| 318 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*)); | |
| 319 | |
| 320 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp | |
| 321 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param | |
| 322 *((void**)stackPtr + 1 ) = initialData; //next param to left | |
| 323 *((void**)stackPtr) = (void*)fnPtr; | |
| 324 | |
| 325 /* | |
| 326 * end of Hardware dependent part | |
| 327 */ | |
| 328 | |
| 329 newPr->stackPtr = stackPtr; //core loop will switch to this, then | |
| 330 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr | |
| 331 | |
| 332 //============================= MEASUREMENT STUFF ======================== | |
| 333 #ifdef STATS__TURN_ON_PROBES | |
| 334 struct timeval timeStamp; | |
| 335 gettimeofday( &(timeStamp), NULL); | |
| 336 newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) - | |
| 337 _VMSMasterEnv->createPtInSecs; | |
| 338 #endif | |
| 339 //======================================================================== | |
| 340 | |
| 341 return newPr; | |
| 342 } | |
| 343 | 284 |
| 344 inline VirtProcr * | 285 inline VirtProcr * |
| 345 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ) | 286 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ) |
| 346 { VirtProcr *newPr; | 287 { VirtProcr *newPr; |
| 347 void *stackLocs; | 288 void *stackLocs; |
