Hi,
One of our threaded process is consuming CPU constantly. It is seen that it is 
calling the time,lwp_park and lwp_unpark continuously.
The logic of the code is explained below
  Thread A               Thread B,C,D,E,...(10 threads)
                         acquire mutex
                         queue is empty
                         cond_wait 
  acquire mutex
  add item N
  release mutex
  cond_broadcast         
                         queue is not empty
                         pop item N from queue
                         release mutex
                         process item N
                         acquire mutex
                         queue is empty
                         cond_wait 

#$ truss -cf -p 14957
^C
syscall               seconds   calls  errors
read                     .015     131
write                    .127     646
open                     .198     153
close                    .052     309
link                     .012      41      41
time                    1.189   35525
stat                     .028     164
lseek                    .012     205
getpid                   .001      20
utime                    .000       1
access                   .041     334     318
kill                     .001      19
shmget                   .001      18      18
lwp_park                1.620   35045
lwp_unpark              1.146   35045
waitid                   .003      19
rename                   .208     123
fork1                   2.090      16
yield                    .028     466
lwp_suspend              .012     208
lwp_continue             .009     221
lwp_sigmask              .000      17
pollsys                  .348    1463
nanosleep                .002      11
so_socket                .019      96
so_socketpair            .016      48
recv                     .066     579
                     --------  ------   ----
sys totals:             7.258  110923    377
usr time:               1.079
elapsed:               21.700
You have new mail in /var/mail/nmsadm
#$ pstack 14957

-----------------  lwp# 1 / thread# 1  --------------------
 fde49c40 nanosleep (ffbf97b8, ffbf97b0)
 0003dcc0 main     (c0708, 0, c06c0, 0, 1800, 326ff8) + 2930
 0002e2c8 _start   (0, 0, 0, 0, 0, 0) + 108
-----------------  lwp# 2 / thread# 2  --------------------
 fde49d04 __time   (fd47bf8c, 0, 0, 1800, c1c28, fde402a0) + 8
 0004fbb0 __MyProcess_0_ (9, bec98, 1800, 9, 9, 1a5c) + 100
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 3 / thread# 3  --------------------
 fde46e18 __lwp_unpark (c1c28, 0, fdec3800, 0, fd4c0a00, c06f4) + 10
 0004fd00 __MyProcess_0_ (9, bec98, 1800, 9, 9, 1a5c) + 250
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 4 / thread# 4  --------------------
 fde46dec lwp_park (0, 0, 0)
 0004fb34 __MyProcess_0_ (9, bec98, 1800, 9, 9, fd27bf5c) + 84
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 5 / thread# 5  --------------------
 fde46e18 __lwp_unpark (c1c28, 0, fdec3800, 0, fd4c1a00, c06f4) + 10
 0004fd00 __MyProcess_0_ (9, bec98, 1800, 9, 9, 1a5c) + 250
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 6 / thread# 6  --------------------
 fde46dec lwp_park (0, 0, 0)
 0004fb34 __MyProcess_0_ (9, bec98, 1800, 9, 9, fd07bf5c) + 84
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 7 / thread# 7  --------------------
 fde46dec lwp_park (0, 0, 0)
 0004fb34 __MyProcess_0_ (9, bec98, 1800, 9, 9, fcf7bf5c) + 84
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 8 / thread# 8  --------------------
 fde46dec lwp_park (0, 0, 0)
 0004fb34 __MyProcess_0_ (9, bec98, 1800, 9, 9, fce7bf5c) + 84
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 9 / thread# 9  --------------------
 fde46dec lwp_park (0, 0, 0)
 0004fb34 __MyProcess_0_ (9, bec98, 1800, 9, 9, fcd7bf5c) + 84
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 10 / thread# 10  --------------------
 fde46e18 __lwp_unpark (c1c28, 0, fdec3800, 0, fd4c4200, c06f4) + 10
 0004fd00 __MyProcess_0_ (9, bec98, 1800, 9, 9, 1a5c) + 250
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-----------------  lwp# 11 / thread# 11  --------------------
 fde46dec lwp_park (0, 0, 0)
 0004fb34 __MyProcess_0_ (9, bec98, 1800, 9, 9, fcb7bf5c) + 84
 fde46d4c _lwp_start (0, 0, 0, 0, 0, 0)
-- 
This message posted from opensolaris.org
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to