资源简介
csapp lab6 malloc lab 完成方法 显示空闲链表 pt96
代码片段和文件信息
/*
* clock.c - Routines for using the cycle counters on x86
* Alpha and Sparc boxes.
*
* Copyright (c) 2002 R. Bryant and D. O‘Hallaron All rights reserved.
* May not be used modified or copied without permission.
*/
#include
#include
#include
#include
#include “clock.h“
/*******************************************************
* Machine dependent functions
*
* Note: the constants __i386__ and __alpha
* are set by GCC when it calls the C preprocessor
* You can verify this for yourself using gcc -v.
*******************************************************/
#if defined(__i386__)
/*******************************************************
* Pentium versions of start_counter() and get_counter()
*******************************************************/
/* $begin x86cyclecounter */
/* Initialize the cycle counter */
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.
Implementation requires assembly code to use the rdtsc instruction. */
void access_counter(unsigned *hi unsigned *lo)
{
asm(“rdtsc; movl %%edx%0; movl %%eax%1“ /* Read cycle counter */
: “=r“ (*hi) “=r“ (*lo) /* and move results to */
: /* No input */ /* the two outputs */
: “%edx“ “%eax“);
}
/* Record the current value of the cycle counter. */
void start_counter()
{
access_counter(&cyc_hi &cyc_lo);
}
/* Return the number of cycles since the last call to start_counter. */
double get_counter()
{
unsigned ncyc_hi ncyc_lo;
unsigned hi lo borrow;
double result;
/* Get cycle counter */
access_counter(&ncyc_hi &ncyc_lo);
/* Do double precision subtraction */
lo = ncyc_lo - cyc_lo;
borrow = lo > ncyc_lo;
hi = ncyc_hi - cyc_hi - borrow;
result = (double) hi * (1 << 30) * 4 + lo;
if (result < 0) {
fprintf(stderr “Error: counter returns neg value: %.0f\n“ result);
}
return result;
}
/* $end x86cyclecounter */
#elif defined(__alpha)
/****************************************************
* Alpha versions of start_counter() and get_counter()
***************************************************/
/* Initialize the cycle counter */
static unsigned cyc_hi = 0;
static unsigned cyc_lo = 0;
/* Use Alpha cycle timer to compute cycles. Then use
measured clock speed to compute seconds
*/
/*
* counterRoutine is an array of Alpha instructions to access
* the Alpha‘s processor cycle counter. It uses the rpcc
* instruction to access the counter. This 64 bit register is
* divided into two parts. The lower 32 bits are the cycles
* used by the current process. The upper 32 bits are wall
* clock cycles. These instructions read the counter and
* convert the lower 32 bits into an unsigned int - this is the
* user space counter value.
* NOTE: The counter has a very limited time span. With a
* 450MhZ clock the c
相关资源
- labview多通道串口数据通讯程序
- 基于帧间差分
- 基于Labview下 可燃气体浓度监测软件
- labview 字符串画
- labview字符串拆分到数组 支持中文1
- 基于labview的温度自动控制PID算法
- IEEE30节点数据268694
- labview打开任意类型文件
- 基于LabVIEW虚拟示波器设计
- labview音乐喷泉
- labview二进制字符串转十进制
- labview NI采集卡多通道采集程序
- 七个RBF神经网络的源程序
- 基于LABVIEW的CAN通信
- labview 交通灯
- labview调用摄像头的vi
- 2015年 LabWindows CVI 3D graph控件编程
- voicebox工具箱
- labview编写比较高级计算器
- UWB system
- 图像亚像素平移
- 模型与模型验证.zip
- coursera斯坦福机器学习公开课支持向量
- 基于LabVIEW的电机转速控制系统设计
- FastSLAM算法模型
- 基于LabVIEW2013的远程多点温度测控系统
- labview modbus
- ics lab8 perflab性能优化实验
- Qt QLabel滚动字幕.zip
- CSAPP 六个重要实验 lab4 实验指导书
评论
共有 条评论