APAR status
Closed as fixed if next.
Error description
PROBLEM DESCRIPTION: . The customer's testcase contains several threads, a main thread that asks for input from the user, and several other threads that act independently of the main thread. The secondary threads go through a loop 1000 times printing to the screen and sleeping the thread. The secondary threads are simulating a server, performing tasks in the background, completely independent of what is going on in the main thread. . The problem is that with C++ V5 and V6 on both AIX 4.3.3 and 5, the thread that asks the user for input is locking all of the other threads while it waits for input from the user. This prevents all of the other threads from executing. . If the method of getting input from the user is changed from getline() to scanf(), the problem goes away; The secondary threads continue to execute while the main thread waits for input from the user. . This problem is not present on Linux using our VAC++ 6.0 for Linux compiler. . TESTCASE: . ******************************* t.C ************************* #include <sstream> #include <pthread.h> #include <stdio.h> #include <unistd.h> #include <syslog.h> #include <iostream> . extern "C" void* func(void* iValue) { int lID = (int) iValue; for(int i = 0; i < 1000; i ++) { // this line will be blocked by the std::cin.getline() std::wstringstream lStream; . printf("Thread %d >>> before sleeping...\n", lID); sleep(1); printf("Thread %d <<< after sleeping...\n", lID); sleep(1); } pthread_exit(0); return (void*) 0; . } . main() { . pthread_t thread[5]; . for(int i =0; i < 5 ; i ++) pthread_create(&thread[i], NULL, func,(void*) i); . for(int i = 0; i< 100; i ++) { sleep(1); char lString[200]; printf("Read:\n"); // this function will wait for user input, // AND block other ios constructors // scanf("%s\n",&lString); std::cin.getline(lString, 200); printf("Got %s\n", lString); } . sleep(100); } ******************************* t.C *********************** . COMPILE COMMAND: . xlC_r t.C . ACTUAL OUTPUT: . on AIX: . $ aix.out Thread 0 >>> before sleeping... Thread 1 >>> before sleeping... Thread 2 >>> before sleeping... Thread 3 >>> before sleeping... Thread 4 >>> before sleeping... Thread 0 <<< after sleeping... Thread 1 <<< after sleeping... Thread 2 <<< after sleeping... Thread 3 <<< after sleeping... Thread 4 <<< after sleeping... Read: . on Linux: . jromano@speeder:/home/jromano/pmr/91517> linux.out Thread 0 >>> before sleeping... Thread 1 >>> before sleeping... Thread 2 >>> before sleeping... Thread 3 >>> before sleeping... Thread 4 >>> before sleeping... Read: Thread 0 <<< after sleeping... Thread 1 <<< after sleeping... Thread 2 <<< after sleeping... Thread 3 <<< after sleeping... Thread 4 <<< after sleeping... Thread 0 >>> before sleeping... Thread 1 >>> before sleeping... Thread 2 >>> before sleeping... Thread 3 >>> before sleeping... Thread 4 >>> before sleeping... <CTRL-C to kill application> . EXPECTED OUTPUT: . The customer expects to see the getline() not to stop all threads while it waits for input. The expected output is seen on out Linux compiler, as well as on AIX when the getline() is changed to scanf().
Local fix
Problem summary
same as submitter's text
Problem conclusion
Temporary fix
no temp fix.
Comments
APAR Information
APAR number
IY45273
Reported component name
VA C++ PROF FOR
Reported component ID
5765F5600
Reported release
600
Status
CLOSED FIN
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt / Xsystem
Submitted date
2003-06-09
Closed date
2003-09-02
Last modified date
2003-09-02
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Modules/Macros
DEFSRXXX
Fix information
Applicable component levels
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSO198","label":"IBM Visualage C++ Professional for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"6.0","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
20 August 2024