GOT A COUPLE OF QUESTIONS REGARDING C++

ITEM: RTA000053461



QUESTION:                                                                       
Got a question about programming message queues and semaphores on               
AIX 3.2.5.  My customer has an application that creates several                 
message queues and semaphores and they a couple of question.                    
1.  Does the msgrcv function poll the message queues or does it wait            
    for something to arrive in the message queues?                              
    My customer has the message queues set up and uses the msgrcv with          
    the WAIT option to check to see if anything arrives in the message          
    queue.  The other day, while running a long job (several days) we           
    noticed that the CPU was fully utilized 99-100% most of the time            
    when the programmer believed that he should not be executing                
    anything but waiting with the msgrcv function.  This was about              
    the second day of running this job so we could not stop it and              
    start it with the debugger (they have C++.)  to find out if                 
    it was really executing the msgrcv function or whether it was              
    stuck in another loop.                                                      
2.  How do they get rid of the message queues and semaphores they               
    create?                                                                     
    My customer says that he has not figured out how to gracefully              
    get rid of the message queues and semaphores so when his jobs               
    quit, they are still hanging around using resources.  He says               
    he has another application that he uses to kill all of the                  
    message queues and semaphores but he would like to find out                 
    how to do it within his C++ application.                                    
                                                                                
---------- ---------- ---------- --------- ---------- ----------                
A: Q1:  Do 'msgrcv' poll?                                                       
                                                                                
A1:  No.  'msgrcv' blocks until a message arrives. If you find your             
     application using 99 percent cpu, you may wish to use 'tprof' to          
     determine which subroutine within your application is using the            
     cpu cycles.  (This will require that your application be compiled          
     with the '-g' flag.)  Full documentation on the 'tprof' command can        
     be found in the 'Performance Tuning Guide' (SC23-2365-03).                 
                                                                                
Q2:  How do I get rid of message queues and semaphore?                          
                                                                                
A2:  All forms of IPC structures (shared memory, message queues, and            
     semaphores) can be listed with the 'ipcs' command.  These structures       
     can then be removed with the 'ipcrm' command.  Both commands are           
     fully documented in InfoExplorer.                                          
                                                                                
     If you wish to perform this function within a C program, then you          
     will want to use the 'semctl' and/or 'msgctl' routines with the            
     'IPC_RMID' flag set in the command field.  Again, these subroutines       
     are fully documented in InfoExplorer.                                      
                                                                                
---------- ---------- ---------- --------- ---------- ----------                
                                                                                
                                                                                
This item was created from library item Q677183      FFPSK                      
                                                                                
Additional search words:                                                        
AIX ALTERNATE COMPILERS CONNECT COUPLE FFPSK GOT INDEX IX JAN95                 
MESSAGE MSG OZNEW PROGRAMMING QUESTION QUEUES REGARDING RELATED                 
RISCL RISCSYSTEM SEMAPHORES SOFTWARE 3.2.5                                      
                                                                                
                                                                                
                                                                                
                                                                               


WWQA: ITEM: RTA000053461 ITEM: RTA000053461
Dated: 06/1996 Category: RISCL
This HTML file was generated 99/06/24~12:43:21
Comments or suggestions? Contact us