1PIP STRESS(8)               System Manager's Manual              PIP STRESS(8)
2
3
4

NAME

6       pip_stress - Priority Inheritance with processes
7

SYNOPSIS

9       pip_stress
10
11

DESCRIPTION

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

AUTHOR

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