[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [root <agn@city.dk>] (fwd)
- To: rtl@rtlinux.org
- Subject: BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [root <agn@city.dk>] (fwd)
- From: Der Herr Hofrat <der.herr@hofr.at>
- Date: Sun, 20 May 2001 14:11:34 +0200 (CEST)
>From owner-rtl Sun May 20 06:46:59 2001
Received: from kalman.iau.dtu.dk (kalman.iau.dtu.dk [192.38.66.22])
by hq.fsmlabs.com (8.11.2/8.11.2) with ESMTP id f4KCkwr11968
for <rtl@rtlinux.org>; Sun, 20 May 2001 06:46:58 -0600
Received: from city.dk (IDENT:root@xterm39 [192.38.66.79])
by kalman.iau.dtu.dk (8.9.3/8.9.3) with ESMTP id OAA01351
for <rtl@rtlinux.org>; Sun, 20 May 2001 14:41:50 +0200
Sender: root@kalman.iau.dtu.dk
Message-ID: <3B07BBD6.CC768C05@city.dk>
Date: Sun, 20 May 2001 14:43:02 +0200
From: root <agn@city.dk>
X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.1-rtl i686)
X-Accept-Language: en
MIME-Version: 1.0
To: rtl@rtlinux.org
Subject: maybee error in sem_getvalue funktion
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi
I have tested the sem_getvalue funktion.
Program.
#include <rtl.h>
#include <rtl_fifo.h>
#include <time.h>
#include <rtl_sched.h>
#include <rtl_sync.h>
#include <pthread.h>
#include <posix/unistd.h>
#include <semaphore.h>
int init_module(void) {
sem_t sem;
int res,val,semres;
semres = sem_init(&sem,0,1);
res = sem_getvalue(&sem,&val);
rtl_printf("TEST sem val %d res %d semres %d \n",val,res,semres);
semres = sem_post(&sem);
res = sem_getvalue(&sem,&val);
rtl_printf("TEST sem val %d res %d semres %d \n",val,res,semres);
semres = sem_wait(&sem);
res = sem_getvalue(&sem,&val);
rtl_printf("TEST sem val %d res %d semres %d \n",val,res,semres);
sem_destroy(&sem);
return 0;
}
void cleanup_module(void) {
}
I get the result.
May 20 14:33:19 xterm39 kernel: TEST sem val -1070961824 res 1 semres 0
May 20 14:33:19 xterm39 kernel: TEST sem val -1070961824 res 2 semres 0
May 20 14:33:19 xterm39 kernel: TEST sem val -1070961824 res 1 semres 0
the return value res from sem_getvalue states the value of the
semaphore. this should be 0 or positiv so this is allright. But the
value of the semaphore is wrong (here val). this should state the value
of the semaphore according to the POSIX standard.
Have there been made any changes to the POSIX standard? (or is this
caused by calling sem_getvalue from init_module?)
Anders Gnistrup.