Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display pthreads priority

Tags:

linux

pthreads

I have a process (testsuit). In this process I use two pthreads ( T1 and T2 ).

Is there a possibility to display information about this threads on the shell ( especially the priority)?

If I use top -H I can see noting.

ps axms show me this

  UID   PID   PENDING   BLOCKED   IGNORED    CAUGHT STAT TTY        TIME COMMAND
    0     1  00000000         -         -         - -    ?          0:00 init [3

    .
    .
    .

    0  1063  00000000         -         -         - -    ttyS0      0:00 ./tests
    0     -  00000000  00000000  00000000 <80000000 Sl   -          0:00 -
    0     -  00000000  00000000  00000000 <80000000 Rl   -          0:00 -
    0     -  00000000  00000000  00000000 <80000000 Rl   -          0:00 -

I think there is no indication of Priority.

That are the things I found out. ( feel free to edit it )

  • UID =
  • PID = process ID
  • PENDING =
  • BLOCKED =
  • IGNORED =
  • CAUGHT =
  • STAT = process state
  • TTY = Terminal associated with the process
  • TIME = cumulated CPU time
  • COMMAND = executable name

NOTE:

I use Linux 2.4.36 without gui

like image 982
Manfred Avatar asked Sep 03 '26 08:09

Manfred


1 Answers

You can use a programmatic way.

   pthread_getschedparam(pthread_t thread, int *policy,
                         struct sched_param *param);

This function gives ya the scheduling parameters, in the struct sched_param you can find the scheduling priority as an integer.
Use that and print it to the screen.

For a better explanation, please check this man page:
http://www.kernel.org/doc/man-pages/online/pages/man3/pthread_setschedparam.3.html

like image 68
Fingolfin Avatar answered Sep 06 '26 23:09

Fingolfin