5

Is there any way to determine whenever a context switch takes place without the use of profilers? I have written a C program to monitor the time taken for different processes in a program to finish execution. I want to show the process/thread context switching as well. The time at which the switch takes place and from prev_id -> curr_id. These 3 informations would be helpful.

Gabe
  • 84,912
  • 12
  • 139
  • 238
Sathya
  • 525
  • 1
  • 8
  • 15

1 Answers1

3

You can observe voluntary_ctxt_switches and nonvoluntary_ctxt_switches values from the /proc/self/status file.

Michał Šrajer
  • 30,364
  • 7
  • 62
  • 85