简体   繁体   English

Linux Scheduler中上下文切换的基准

[英]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)以获取每个上下文切换时间的近似值。

  • Does this benchmark make sense? 这个基准有意义吗?
  • Would it make sense to study the time per context switch with different numbers of threads, or is it theoretically constant? 研究具有不同线程数的每个上下文切换的时间是否有意义,或者理论上是恒定的?
  • Is there a better way to design the benchmark? 有没有更好的方法来设计基准?

这是一个很好的起点: https : //github.com/tsuna/contextswitch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM