[英]Benchmark for the context switches in linux scheduler
I have an assignment to design a benchmark for the linux scheduler in C, more precisely to "determine how the underlying architecture handles context switches, without looking at the details of the implementation." 我的任务是为C语言中的Linux调度程序设计一个基准,更准确地说是“确定底层体系结构如何处理上下文切换,而无需查看实现细节”。
Based on an article I found on the linux journal, I have designed a benchmark that measures the time it takes to spawn a process (fork/exec) and to create a thread (fork). 基于我在linux期刊上找到的一篇文章,我设计了一个基准测试,该基准测试用于生成进程(fork / exec)和创建线程(fork)所花费的时间。
Now I want to test the time it takes to switch process and thread, with the instruction sched_yield. 现在,我要使用指令sched_yield测试切换进程和线程所需的时间。 I thought of creating multiple threads/processes and having them all call sched_yield.
我想到创建多个线程/进程并将它们全部称为sched_yield。 The first thread/process to call sched_yield would measure the time and divide it by the number of processes (I assume that all other processes call sched_yield before the first process resumes execution) to get an aproximation of the time per context switch.
第一个调用sched_yield的线程/进程将测量时间并将其除以进程数(我假设在第一个进程恢复执行之前,所有其他进程都调用sched_yield)以获取每个上下文切换时间的近似值。
这是一个很好的起点: https : //github.com/tsuna/contextswitch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.