diff 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
line diff
     1.1 --- a/VMS.c	Mon Aug 09 02:24:31 2010 -0700
     1.2 +++ b/VMS.c	Wed Sep 01 08:32:04 2010 -0700
     1.3 @@ -267,14 +267,14 @@
     1.4     newPr->procrID     = numProcrsCreated++;
     1.5     newPr->nextInstrPt = fnPtr;
     1.6     newPr->initialData = initialData;
     1.7 +   newPr->requests    = NULL;
     1.8  
     1.9        //fnPtr takes two params -- void *initData & void *animProcr
    1.10        //alloc stack locations, make stackPtr be the highest addr minus room
    1.11        // for 2 params + return addr.  Return addr (NULL) is in loc pointed to
    1.12        // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above
    1.13     stackLocs = malloc( VIRT_PROCR_STACK_SIZE );
    1.14 -   if(stackLocs == 0)
    1.15 -   {perror("malloc stack"); exit(1);}
    1.16 +   if(stackLocs == 0)   {perror("malloc stack"); exit(1);}
    1.17     newPr->startOfStack = stackLocs;
    1.18     stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 );
    1.19        //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
    1.20 @@ -350,22 +350,6 @@
    1.21  
    1.22  
    1.23  
    1.24 -/*This is equivalent to "jump back to core loop" -- it's mainly only used
    1.25 - * just after adding dissipate request to a processor -- so the semantic
    1.26 - * layer is the only place it will be seen and/or used.
    1.27 - *
    1.28 - *It does almost the same thing as suspend, except don't need to save the
    1.29 - * stack nor set the nextInstrPt
    1.30 - *
    1.31 - *As of June 30, 2010  just implementing as a call to suspend -- just sugar
    1.32 - */
    1.33 -void
    1.34 -VMS__return_from_fn( VirtProcr *animatingPr )
    1.35 - {
    1.36 -   VMS__suspend_procr( animatingPr );
    1.37 - }
    1.38 -
    1.39 -
    1.40  /*Not sure yet the form going to put "dissipate" in, so this is the third
    1.41   * possibility -- the semantic layer can just make a macro that looks like
    1.42   * a call to its name, then expands to a call to this.
    1.43 @@ -458,6 +442,19 @@
    1.44     return req;
    1.45   }
    1.46  
    1.47 +VMSReqst *
    1.48 +VMS__free_top_and_give_next_request_from( VirtProcr *procrWithReq )
    1.49 + { VMSReqst *req;
    1.50 +
    1.51 +   req = procrWithReq->requests;
    1.52 +   if( req == NULL ) return req;
    1.53 +
    1.54 +   procrWithReq->requests = procrWithReq->requests->nextReqst;
    1.55 +   VMS__free_request( req );
    1.56 +   return procrWithReq->requests;
    1.57 + }
    1.58 +
    1.59 +
    1.60  inline int
    1.61  VMS__isSemanticReqst( VMSReqst *req )
    1.62   {