comparison VMS.c @ 32:65e5918731b8

Bugfix: initialize request pointer to NULL in newly created VP
author Me
date Wed, 01 Sep 2010 08:32:04 -0700
parents c8823e0bb2b4
children d6367cd40e21 63790b19f742
comparison
equal deleted inserted replaced
12:e65c232fa04b 14:b3cadd877ad5
265 265
266 newPr = malloc( sizeof(VirtProcr) ); 266 newPr = malloc( sizeof(VirtProcr) );
267 newPr->procrID = numProcrsCreated++; 267 newPr->procrID = numProcrsCreated++;
268 newPr->nextInstrPt = fnPtr; 268 newPr->nextInstrPt = fnPtr;
269 newPr->initialData = initialData; 269 newPr->initialData = initialData;
270 newPr->requests = NULL;
270 271
271 //fnPtr takes two params -- void *initData & void *animProcr 272 //fnPtr takes two params -- void *initData & void *animProcr
272 //alloc stack locations, make stackPtr be the highest addr minus room 273 //alloc stack locations, make stackPtr be the highest addr minus room
273 // for 2 params + return addr. Return addr (NULL) is in loc pointed to 274 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
274 // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above 275 // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above
275 stackLocs = malloc( VIRT_PROCR_STACK_SIZE ); 276 stackLocs = malloc( VIRT_PROCR_STACK_SIZE );
276 if(stackLocs == 0) 277 if(stackLocs == 0) {perror("malloc stack"); exit(1);}
277 {perror("malloc stack"); exit(1);}
278 newPr->startOfStack = stackLocs; 278 newPr->startOfStack = stackLocs;
279 stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 ); 279 stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 );
280 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp 280 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
281 *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer 281 *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer
282 *( (int *)stackPtr + 1 ) = (int) initialData; //next param to left 282 *( (int *)stackPtr + 1 ) = (int) initialData; //next param to left
348 return; 348 return;
349 } 349 }
350 350
351 351
352 352
353 /*This is equivalent to "jump back to core loop" -- it's mainly only used
354 * just after adding dissipate request to a processor -- so the semantic
355 * layer is the only place it will be seen and/or used.
356 *
357 *It does almost the same thing as suspend, except don't need to save the
358 * stack nor set the nextInstrPt
359 *
360 *As of June 30, 2010 just implementing as a call to suspend -- just sugar
361 */
362 void
363 VMS__return_from_fn( VirtProcr *animatingPr )
364 {
365 VMS__suspend_procr( animatingPr );
366 }
367
368
369 /*Not sure yet the form going to put "dissipate" in, so this is the third 353 /*Not sure yet the form going to put "dissipate" in, so this is the third
370 * possibility -- the semantic layer can just make a macro that looks like 354 * possibility -- the semantic layer can just make a macro that looks like
371 * a call to its name, then expands to a call to this. 355 * a call to its name, then expands to a call to this.
372 * 356 *
373 *As of June 30, 2010 this looks like the top choice.. 357 *As of June 30, 2010 this looks like the top choice..
455 if( req == NULL ) return req; 439 if( req == NULL ) return req;
456 440
457 procrWithReq->requests = procrWithReq->requests->nextReqst; 441 procrWithReq->requests = procrWithReq->requests->nextReqst;
458 return req; 442 return req;
459 } 443 }
444
445 VMSReqst *
446 VMS__free_top_and_give_next_request_from( VirtProcr *procrWithReq )
447 { VMSReqst *req;
448
449 req = procrWithReq->requests;
450 if( req == NULL ) return req;
451
452 procrWithReq->requests = procrWithReq->requests->nextReqst;
453 VMS__free_request( req );
454 return procrWithReq->requests;
455 }
456
460 457
461 inline int 458 inline int
462 VMS__isSemanticReqst( VMSReqst *req ) 459 VMS__isSemanticReqst( VMSReqst *req )
463 { 460 {
464 return ( req->reqType == semantic ); 461 return ( req->reqType == semantic );