使用 pthread_yield() 从 Rhealstone 基准测试得出的任务切换时间
我正在尝试在 Linux 中实现任务切换 Rhealstone 基准测试。这是原始代码: http://pastebin.com/aYF4Tnvt
这是我到目前为止所写的内容: http://pastebin.com/tX7zK7h7
问题是 for 循环随机运行几次,并且程序退出。任何人都可以指出我正确的方向吗?我是一个菜鸟程序员,我真的对这些东西迷失了。
I'm trying to implement the task switch Rhealstone benchmark in Linux. Here is the original code:
http://pastebin.com/aYF4Tnvt
And here is what I've written so far:
http://pastebin.com/tX7zK7h7
The problem is that the for loops run for a random few times and the program quits. Anyone can point me to the right direction? I'm a noob programmer and I'm really lost with this stuff.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
join() main() 中的线程。您正在退出主程序并退出程序,这会杀死其他线程。将代码更改为类似
不确定要将结束计时器放置在何处。通过这种方式,您还可以对 join() 的两次调用进行计时,但它们应该是最少的。如果您将计时器放在连接之前,那么您将在线程实际结束之前结束计时器 - 您将计时的是两个 create_thread 调用完成所需的时间。
join() the threads in main(). You are falling out of main and exiting your program which kills the other threads. Change the code to something like
Not sure exactly where you want to put that end timer. In this manner you would also be timing the two calls to join() but they should be minimal. If you put the timer before the join then you will be ending your timer way before your threads actually end - all you will be timing is how long it takes to for two create_thread calls to complete.