From owner-freebsd-questions Sat Apr 25 00:13:28 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA18216 for freebsd-questions-outgoing; Sat, 25 Apr 1998 00:13:28 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from mx.nsu.ru (root@mx.nsu.ru [193.124.215.71]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA18209 for ; Sat, 25 Apr 1998 00:13:16 -0700 (PDT) (envelope-from div@nsu.ru) Received: from alexandr (ppp37.nsu.ru [193.124.209.37]) by mx.nsu.ru (8.8.8/8.8.5/kkg/antispam/antirelay/28.Sep.97) with ESMTP id OAA17632 for ; Sat, 25 Apr 1998 14:12:30 +0700 (NOVST) Message-Id: <199804250712.OAA17632@mx.nsu.ru> From: "=?KOI8-R?Q?=FB=C1=D4=C1=C5=D7_=E1=CC=C5=CB=D3=C1=CE=C4=D2?=" To: "Q:FreeBSD" Subject: pthread question Date: Sat, 25 Apr 1998 14:12:53 -0000 X-MSMail-Priority: Normal X-Priority: 3 X-Mailer: Microsoft Internet Mail 4.70.1161 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_01BD7054.3C797B00" Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Это сообщение в формате MIME состоит из нескольких частей. ------=_NextPart_000_01BD7054.3C797B00 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Hi, all I can not understand the reason of a problem with which I has met. This problem consists in that that in multithread application active thread with no system calls references does not allow other threads to work. I can demonstrate it by attached test program. The purpose of this test is a reception of external timer for active thread which can has (in general) long periods of work without system calls. Thus here is thread with blind infinite loop and initial thread with loop of interval sleep (usleep/setitimer, nanosleep, select timeout - no difference). On my system (2.2.6) initial thread creates child thread and goes to sleep, there is the context switch to child thread without return - child thread runs forever. Little history. I develop some virtual machine as a kernel for database engine. It runs some multithread (not a pthread) pseudocode and uses external clock(SIGALRM/setitimer before) for context switching. I'v used pthreads in this situation for my async IO system. But after I have updated system (2.2.2 -> 2.2.6) there was the above mentioned problem. Sometimes signals are lost sometimes signal handlers, select timeout wait realisation of external clock was unsuccessfull. If you will have ideas on this occassion I shall be rather glad to listen. Beforehand grateful, Boris Muratshin. ------=_NextPart_000_01BD7054.3C797B00 Content-Type: application/octet-stream; name="test2.cc" Content-Transfer-Encoding: 7bit Content-Description: test2.cc () Content-Disposition: attachment; filename="test2.cc" #include #include #include #include #include #include #include extern "C" int nanosleep( const struct timespec* , struct timespec* ); void sigvt( int n) { printf("---%d",n); fflush(0); } void *proc2( void*p ) { for (;;) { for (int j=0;j<10000000;j++); // printf("!"); // fflush(0); // pthread_yield(); } return NULL; } int main( ) { struct timespec ts={0,10000000}; struct timeval tv={0,10000}; pthread_t thread2; pthread_create(&thread2,NULL,proc2,"bbb"); for (;;) { printf("<"); fflush(0); select(0,NULL,NULL,NULL,&tv); // usleep(10000); // nanosleep(&ts,NULL); printf(">"); fflush(0); } return 0; } ------=_NextPart_000_01BD7054.3C797B00-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message