1PIP STRESS(8)               System Manager's Manual              PIP STRESS(8)
2
3
4
5# SPDX-License-Identifier: GPL-2.0-or-later
6

NAME

8       pip_stress - Priority Inheritance with processes
9

SYNOPSIS

11       pip_stress
12
13

DESCRIPTION

15       This  program  demonstrates the technique of using priority inheritance
16       (PI) mutexes with processes instead of threads.  The way to do this  is
17       to  obtain  some  shared  memory  - in this case with mmap that backs a
18       pthread_mutex_t since this will support PI.  Pay  particular  attention
19       to   how   this   is   intialized   to   support  processes.   Function
20       init_shared_pthread_mutex() does this by setting the  pthread_mutexattr
21       to  PTHREAD_PROCESS_SHARED  and  the mutex protocol to PTHREAD_PRIO_IN‐
22       HERIT.  In this program we purposely try to invoke a  classic  priority
23       inversion.   A low priority process grabs the mutex and does some work.
24       A high priority process comes a long and is blocked since the mutex  is
25       taken.   A  medium priority process that doesn't require the mutex then
26       takes the processor. Because the processes are restricted to  one  cpu,
27       the  low priority processes never makes any progress because the medium
28       priority process runs in an infinite loop. This is a priority inversion
29       because  the medium priority process is running at the expensive of the
30       high priority process. However, since we have used PRIO_INHERIT and are
31       running  on  a  machine  that  supports  preemption,  the high priority
32       process will lend it's priority to the low priority process which  will
33       preempt the medium priority process. The low priority process will then
34       release the mutex which the high priority process can obtain. When  the
35       high priority process gets to run it kills the medium priority process.
36       The state structure keeps track of the progress. Although this  program
37       is  set  up  to likely trigger an inversion, there is no guarantee that
38       scheduling will make that happen. After the program  completes  it  re‐
39       ports whether a priority inversion occurred or not. In either case this
40       program demonstrates how to use priority inheritance mutexes with  pro‐
41       cesses.  In fact, you would be better off to avoid scenarios in which a
42       priority inversion occurs if possible - this program tries  to  trigger
43       them  just to show that it works. If you are having difficulty trigger‐
44       ing an inversion, merely  increase  the  time  that  the  low  priority
45       process  sleeps  while  holding  the lock. (usleep); Also note that you
46       have to run as a user with permission to change scheduling  priorities.
47
48

AUTHOR

50       pip_stress was written by John Kacur <jkacur at redhat.com>
51
52       This manual page was also written by John Kacur
53
54
55
56                              September 17, 2018                 PIP STRESS(8)
Impressum