Beispiel #1
0
void stop_trace(int locations, int flag) {
    int tape_stats[statSize];
    int i,sizer;

    int loc_ptr;
    /* int op_cnt,loc_cnt,val_cnt,access_ptr; */

    loc_ptr = locations;
    put_op(end_of_tape);        /* Mark end of tape. */

    tape_stats[0] = ind_ptr;
    tape_stats[1] = dep_ptr;
    tape_stats[2] = loc_ptr;
    tape_stats[3] = vs_ptr;
    tape_stats[4] = BUFSIZE;
    close_tape(tape_stats,flag); /** closes the tape, files up stats, and
                                       writes the tape stats to the integer
                                       tape. **/

    sizer = sizeof(revreal)*(vs_ptr);
    if (revalso)
        taylor_close(sizer/(1+sizer/TBUFSIZE),dep_ptr,ind_ptr);
    for (i=0; i<statSize; i++)
        stats[tag][i]=tape_stats[i];
}
Beispiel #2
0
void CMT::rec_tape(const _TCHAR* file_path)
{
	close_tape();
	
	if(fio->Fopen(file_path, FILEIO_WRITE_BINARY)) {
		my_tcscpy_s(rec_file_path, _MAX_PATH, file_path);
		bufcnt = 0;
		rec = true;
	}
}
Beispiel #3
0
K read_tape(I i, I type) // type in {0,1} -> {select loop, 4: resp reader}
{
  I c=CP[i].r, m=sizeof(M1),g; K z=0;
  S b = c<m?c+(S)&CP[i].m1:c+kC(CP[i].k); 
  g = c<m?m-c:CP[i].m1.n; 
  I nbytes = recv(i,b,g,0); 
  if(nbytes <= 0)
  {
    if (nbytes == 0);//printf("server: socket %ld hung up\n", i);
    else perror("recv");
    GC;
  }
  //fill struct data + k data 
  CP[i].r += nbytes; //DO(nbytes, O("b%ld : %o\n",i,(UC)b[i]))
  if(m == CP[i].r) //We've read enough bytes to fill our struct m1 with transmission data (it's also the _db header)
  {
    //TODO: so that we get the right sizes, etc, in the M1, rearrange bytes based on little-endianness indicator CP[i].m1.a
    //if(sizeof(M1)+CP[i].m1.n > 987654321) GC; //protect against too big?
    K k = newK(-3, m+CP[i].m1.n);
    if(!(CP[i].k=k))GC;
    memcpy(kC(k),&CP[i].m1,m); //cpy data from our struct to the corresponding spot on the '_bd' object
  }
  if(CP[i].r == m + CP[i].m1.n) //the k for the _db is completed. perform modified execution, potentially respond
  {
    //TODO: (here or in _db?) rearrange bytes based on little-endianness indicator CP[i].m1.a
    M1*p=(V)kC(CP[i].k);
    I msg_type = p->d; //p->d dissappears after wipe_tape
    K h = _db(CP[i].k);
    if(!h) GC;
    wipe_tape(i);

    //blocking read inside 4: receives response //response sent by server to client after a 4: request is not executed by client
    if(2==msg_type && 1==type) R h; 

    //Modified execution of received K value. First received transmission in a 3: or 4: 
    z=modified_execute(h);
    cd(h);
    //indicates received communication from 4: synchronous method which expects response
    if(z) if(1==msg_type && 0==type) ksender(i,z,2);
    cd(z); z=0;
  }

  R z;
cleanup:
  close_tape(i);
  R (K)-1;
}
Beispiel #4
0
void CMT::play_tape(const _TCHAR* file_path)
{
	close_tape();
	
	if(fio->Fopen(file_path, FILEIO_READ_BINARY)) {
		fio->Fseek(0, FILEIO_SEEK_END);
		int size = (fio->Ftell() + 9) & (BUFFER_SIZE - 1);
		fio->Fseek(0, FILEIO_SEEK_SET);
		memset(buffer, 0, sizeof(buffer));
		fio->Fread(buffer, sizeof(buffer), 1);
		fio->Fclose();
		
		// send data to sio
		// this implement does not care the sio buffer size... :-(
		for(int i = 0; i < size; i++) {
			d_sio->write_signal(SIG_I8251_RECV, buffer[i], 0xff);
		}
		play = true;
	}
}
Beispiel #5
0
void CMT::reset()
{
	close_tape();
	play = rec = false;
}