Debian Codegraph @

src/pi_tests/pip_stress.8

raw
1 .\"
2 .TH PIP\ STRESS 8 "September 17, 2018"
3 # SPDX-License-Identifier: GPL-2.0-or-later
4 .SH NAME
5 .B pip_stress \- Priority Inheritance with processes
6 .SH SYNOPSIS
7 .B pip_stress
8 .RB [ \-u|\-\-usleep
9 .IR TIME ]
10 .SH DESCRIPTION
11 This program demonstrates the technique of using priority inheritance (PI)
12 mutexes with processes instead of threads.
13 The way to do this is to obtain some shared memory - in this case with
14 mmap that backs a pthread_mutex_t since this will support PI.
15 Pay particular attention to how this is intialized to support processes.
16 Function init_shared_pthread_mutex() does this by setting the
17 pthread_mutexattr to PTHREAD_PROCESS_SHARED and the mutex protocol to
18 PTHREAD_PRIO_INHERIT.
19 In this program we purposely try to invoke a classic priority inversion.
20 A low priority process grabs the mutex and does some work.
21 A high priority process comes a long and is blocked since the mutex is taken.
22 A medium priority process that doesn't require the mutex then takes the
23 processor. Because the processes are restricted to one cpu, the low priority
24 processes never makes any progress because the medium priority process
25 runs in an infinite loop. This is a priority inversion because the
26 medium priority process is running at the expensive of the high priority
27 process. However, since we have used PRIO_INHERIT and are running on a
28 machine that supports preemption, the high priority process will lend it's
29 priority to the low priority process which will preempt the medium priority
30 process. The low priority process will then release the mutex which the
31 high priority process can obtain. When the high priority process gets to run
32 it kills the medium priority process.
33 The state structure keeps track of the progress. Although this program
34 is set up to likely trigger an inversion, there is no guarantee that
35 scheduling will make that happen. After the program completes it reports
36 whether a priority inversion occurred or not. In either case this program
37 demonstrates how to use priority inheritance mutexes with processes.
38 In fact, you would be better off to avoid scenarios in which a priority
39 inversion occurs if possible - this program tries to trigger them just
40 to show that it works. If you are having difficulty triggering an inversion,
41 merely increase the time that the low priority process sleeps while
42 holding the lock. (usleep);
43 Also note that you have to run as a user with permission to change
44 scheduling priorities.
45 .SH OPTIONS
46 .IP "\-u TIME,\-\-usleep=TIME"
47 Specify the sleep time in usec of the low priority process. Defaults to 500.
48 .BR
49 .SH AUTHOR
50 pip_stress was written by John Kacur <jkacur at redhat.com>
51 .PP
52 This manual page was also written by John Kacur