资源简介
icarnegie ssd6 exercise6 答案

代码片段和文件信息
/*
test.cpp
A test program for the timestamp library.
*/
#include
using namespace std;
#include
#include
#include
#include
#include
#include se.h>
#include “tsc.h“
/*
void spin( int thread_number int iteration_count
int report_mode int threshold )
Create a table of readings from the timestamp counter
and print a report to stdout.
report_mode should be either REP_DUMP in which case all
the entries should be output or REP_SWITCH in which case
only the switches should be noted. In the latter case
threshold will be used as a threshold for what constitutes
a switch unless it‘s 0 in which case the minimum threshold
will be calculated.
*/
void spin( int process_number
int iteration_count
int report_mode
int report_count
int threshold );
/*
int make_thread( ... )
Create a thread to run spin() passing it the given arguments
and return 0. Or fail and return 1.
*/
int make_thread( int process_number
int iteration_count
int report_mode
int report_count
int threshold );
/*
Cruft needed to get threads working
*/
#ifdef _MSC_VER
#include
#include se.h>
#include
/*
semaphore synchronization primitive.
*/
typedef HANDLE sem_t;
CRITICAL_SECTION output_lock;
/*
Initialise a semaphore.
*/
void sem_init( sem_t *sem int init int max ) {
*sem = CreateSemaphore( NULL init max NULL );
}
/*
Wait for a semaphore (the P() operation).
*/
void sem_wait( sem_t *sem ) {
WaitForSingleobject( *sem INFINITE );
}
/*
Release a semaphore (the V() operation ).
*/
void sem_release( sem_t *sem ) {
ReleaseSemaphore( *sem 1 0 );
}
/*
The semaphore for threads returning.
*/
sem_t semaphore;
signed __int64 gstart;
struct spin_args {
spin_args( int p int i int d int r int t ) {
process_number = p;
iteration_count = i;
report_type = d;
report_count = r;
threshold = t;
}
int process_number;
int iteration_count;
int report_type;
int report_count;
int threshold;
};
/*
This is the function we want _beginthread to spawn at.
*/
void __cdecl _msc_spin( void *param ) {
spin_args args = *((spin_args *) param);
delete (spin_args *) param;
spin( args.process_number args.iteration_count
args.report_type args.report_count args.threshold );
sem_release( &semaphore );
}
/*
Create the thread.
*/
int make_thread( int p int i int o int r int t ) {
spin_args *s = new spin_args( p i o r t );
sem_wait( &semaphore );
if (_beginthread( &_msc_spin 0 s ) == -1) {
sem_release( &semaphore );
cerr << “...failed: “ << errno << endl;
return 1;
}
return 0;
}
#endif
void calc(void * param) {
// Old algorithm fails under certain OS‘s on mobile processors
// becaus
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 475 2010-01-26 11:12 ex6\part1\graph\answers.txt
文件 3163 2002-10-11 11:49 ex6\part1\graph\clsData.cls
文件 1586 2002-10-11 09:09 ex6\part1\graph\clsThread.cls
文件 14243 2002-10-29 09:55 ex6\part1\graph\frmGraph.frm
文件 49152 2002-10-29 09:57 ex6\part1\graph\graph.exe
文件 802 2002-10-29 09:56 ex6\part1\graph\graph.vbp
文件 2061 2010-01-26 01:47 ex6\part1\graph\output.out
文件 20543 2010-01-16 11:45 ex6\part1\graph.zip
文件 125 2010-01-26 01:44 ex6\part1\Timestamp\run.cmd
文件 32 2010-01-16 14:50 ex6\part1\Timestamp\simplerun.cmd
文件 10388 2008-05-02 21:24 ex6\part1\Timestamp\test.cpp
文件 184320 2005-08-17 11:31 ex6\part1\Timestamp\Timestamp.exe
文件 4069 2008-05-02 21:27 ex6\part1\Timestamp\Timestamp.vcproj
文件 2126 2002-10-04 14:12 ex6\part1\Timestamp\tsc.c
文件 1158 2002-08-03 19:19 ex6\part1\Timestamp\tsc.h
文件 92755 2010-01-16 11:45 ex6\part1\Timestamp.zip
文件 6244 2010-01-26 12:55 ex6\part2\threadedclient\Debug\BuildLog.htm
文件 67 2010-01-26 12:55 ex6\part2\threadedclient\Debug\mt.dep
文件 3 2010-01-26 12:41 ex6\part2\threadedclient\Debug\run.cmd
文件 60416 2010-01-26 12:55 ex6\part2\threadedclient\Debug\tclient.exe
文件 621 2010-01-26 12:55 ex6\part2\threadedclient\Debug\tclient.exe.intermediate.manifest
文件 437960 2010-01-26 12:55 ex6\part2\threadedclient\Debug\tclient.ilk
文件 601088 2010-01-26 12:55 ex6\part2\threadedclient\Debug\tclient.pdb
文件 66217 2010-01-26 12:55 ex6\part2\threadedclient\Debug\ThreadedClient.obj
文件 461824 2010-01-26 12:55 ex6\part2\threadedclient\Debug\vc90.idb
文件 266240 2010-01-26 12:55 ex6\part2\threadedclient\Debug\vc90.pdb
文件 59904 2008-05-02 21:02 ex6\part2\threadedclient\sclient.exe
文件 1241 2005-03-25 18:09 ex6\part2\threadedclient\servers.h
文件 100221 2008-05-02 20:36 ex6\part2\threadedclient\servers.obj
文件 59904 2008-05-02 21:02 ex6\part2\threadedclient\tclient.exe
............此处省略16个文件信息
相关资源
- 数据库系统基础教程答案第三版机械
- 《数字信号处理第三版》课后习题答
- 数据结构年终考题范围和答案 耿国华
- 大学物理答案 同济大学 高等教育出版
- 信息论与编码(仇佩亮编著 高等教育
- 《复变函数》习题答案(第四版)
- 中科院 编译原理 习题及解答
- 西安电子科技大学 并行计算 霍红卫
- 浙江工业大学2005-2006学年单片机习题
- 信息系统分析与设计试卷及答案
- SSD4 exercise8答案
- 杨素行第三版模电答案
- 复变函数参考答案(西安交通大学版
- 复旦大学出版社 李贤平 《概率论基础
- 数值分析答案(第五版)李庆扬
- 数据结构殷人昆版的课后答案
- 郁道银 工程光学 习题答案
- 操作系统教程课后答案华中科技大学
- 用友ERP考试系统练习题库及答案
- 《原子物理学》高教 杨福家 完整版课
- 真正!!!概率论与数理统计浙江大
- 计算机操作系统课后_汤小丹_第四版
- 计算机操作系统(第四版)汤小丹课
- 南京大学考研845真题答案-2018
- Convex Optimization 习题答案
- 数据结构考研试题历届试卷(附答案
- 计算机网络自顶向下方法答案(第六
- 数学分析教材,复旦,陈传璋、金福
- 操作系统教程课后习题答案
- 编译原理龙书答案
评论
共有 条评论