Generating controlled load on Linux CPU cores using just C!

Описание к видео Generating controlled load on Linux CPU cores using just C!

Hi,
in this video we are going to discus an approach to generate controlled load on all or selected CPU cores present in our Linux system and then implement a tiny C program/tool to actually do it. Here by load I mean CPU utilization that is the CPU utilization percentages we see per core when we run htop in our terminal. Also by controlled I mean we will try to generate a specific load percentage for a given amount of time. For example something like 60% cpu utilization for all or some of the cores for lets say 30 seconds.
In reality we already have a very popular tool called stress-ng to achieve the same thing however I wanted to find out how we can generate such controlled CPU load from scratch and hence thought of implementing something similar.
Some of the interesting things we will be discussing in this video are the sysconf API which lets us query system parameters at runtime, the gettimeofday API in C which let us get precision timestamp, the nanosleep API and the awesome sched_setaffinity system call which allows us to pin process to a particular CPU core in Linux.

Hope you will like this video and also do let me know in the comments what approach you would have taken to generate such CPU load in Linux.

Timestamps:
0:00 Introduction and what we plan to do
4:18 Some basic stuff
7:43 Our approach
16:39 Implementing load generation
40:39 Testing our program
43:51 CPU pinning

Code:
https://github.com/djmgit/cpuloadgen

Asset:
Image by Michael Schwarzenberger from Pixabay

Resources:
https://qxf2.com/blog/generate-cpu-load/
Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham,
and Alex Samuel

#cprogramming #linux #kernel #linuxkernel #cpu #processor #programming #systems #stress #cpustress #cpuload #coding #systemcalls #devops #sre

Комментарии

Информация по комментариям в разработке