Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/10/2010, 13:09
Avatar de Lizy94
Lizy94
 
Fecha de Ingreso: diciembre-2009
Mensajes: 149
Antigüedad: 16 años, 10 meses
Puntos: 0
duda con linea de condigo

Hola foro, bueno viendo unos codigos me encontré con esta línea , q no entiendo q hace

borrow = lo > ncyc_lo;

y otra pregunta este contador es para leer un contador de q ??? , de los ciclos de reloj??
Código PHP:

static unsigned cyc_hi = 0; 
static 
unsigned cyc_lo = 0; 
/* Set *hi and *lo to the high and low order bits 
of the cycle counter. 
*/ 
void access_counter(unsigned *hi, unsigned *lo) 
{ 
asm(
"rdtsc; movl %%edx,%0; movl %%eax,%1 
: "
=r" (*hi), "=r" (*lo) 
: 
: "
%edx", "%eax")"; 
} 

/*record the current value of cycle counter.*/

void start_counter() 
{ 
access_counter(&cyc_hi, &cyc_lo); 
} 

/* Number of cycles since the last call to start_counter. */ 
double get_counter() 
{ 
  
unsigned ncyc_hi, ncyc_lo; 
  
unsigned hi, lo, borrow; 
  
/* Get cycle counter */ 
  
access_counter(&ncyc_hi, &ncyc_lo); 
  
/* Do double precision subtraction */ 
  
lo = ncyc_lo - cyc_lo; 
  
borrow = lo > ncyc_lo; //esto que hace??
  
hi = ncyc_hi - cyc_hi - 
  
borrow; 
return (double) 
hi * (1 << 30) * 4 + lo; 
} 

Última edición por Lizy94; 12/10/2010 a las 13:38