资源简介
CSAPP上的存储山 可以在linux运行 但是不知道怎么弄成图形的
只能在终端界面显示一堆数字
tar vxf mountain tar
cd mountain
make
mountain
代码片段和文件信息
#include
#include
#include
#include
#include “clock.h“
/* Routines for using cycle counter */
/* Detect whether running on Alpha */
#ifdef __alpha
#define IS_ALPHA 1
#else
#define IS_ALPHA 0
#endif
/* Detect whether running on x86 */
#ifdef __i386__
#define IS_x86 1
#else
#define IS_x86 0
#endif
/* Keep track of most recent reading of cycle counter */
static unsigned cyc_hi = 0;
static unsigned cyc_lo = 0;
#if IS_ALPHA
/* 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 counter can time things for about 9
* seconds. */
static unsigned int counterRoutine[] =
{
0x601fc000u
0x401f0000u
0x6bfa8001u
};
/* Cast the above instructions into a function. */
static unsigned int (*counter)(void)= (void *)counterRoutine;
void start_counter()
{
/* Get cycle counter */
cyc_hi = 0;
cyc_lo = counter();
}
double get_counter()
{
unsigned ncyc_hi ncyc_lo;
unsigned hi lo borrow;
double result;
ncyc_lo = counter();
ncyc_hi = 0;
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: Cycle counter returning negative value: %.0f\n“ result);
}
return result;
}
#endif /* Alpha */
#if IS_x86
void access_counter(unsigned *hi unsigned *lo)
{
/* Get cycle counter */
asm(“rdtsc; movl %%edx%0; movl %%eax%1“
: “=r“ (*hi) “=r“ (*lo)
: /* No input */
: “%edx“ “%eax“);
}
void start_counter()
{
access_counter(&cyc_hi &cyc_lo);
}
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: Cycle counter returning negative value: %.0f\n“ result);
}
return result;
}
#endif /* x86 */
double ovhd()
{
/* Do it twice to eliminate cache effects */
int i;
double result;
for (i = 0; i < 2; i++) {
start_counter();
result = get_counter();
}
return result;
}
/* Determine clock rate by measuring cycles
elapsed while sleeping for sleeptime seconds */
double mhz_full(int verbose int sleeptime)
{
double rate;
start_counter();
sleep(s
相关资源
- 深入理解计算机系统真题
- 中科大csapp实验4 perflab-handout 代码优化
- CSAPP: shell lab 解答
- 南京大学CSAPP lab5-9
- csapp中文第三版pdf(深入理解计算机操
- 计算机系统试卷
- 哈工大CSAPP期末考试题目.docx
- 哈工大计算机系统实验6
- CSAPP malloc lab答案满分
- 完整版csapp proxy lab 满分原创北大cmu
- CSAPP习题答案
- csapp lab malloclab
- Mac OS X 山狮系统 Install OS X Mountain Li
- 原版Mac OS X Mountain Lion 10.8.5种子
- 苹果操作系统OS X Mountain Lion 10.8 官方
- 哈工大计算机系统实验lab4
- 哈工大计算机系统实验2程序以及实验
- 复旦961考研ppt数据结构 csapp 软件工程
评论
共有 条评论