Skip to contentSkip to conversation

Jan Kiszka : Native: Fix return code of in-kernel rt_cond_wait[_until]

Xenomai-core Gilles Chanteperdrix 2 participants 23 messages Mar 2, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 27 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 10 lines
ksrc/skins/native/cond.c +4 -4
 				    timeout_mode, timeout);
 
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

Signature · 1 line
					    Gilles.
#2 lore raw
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 11 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

Jan

#3 lore raw
Quoted 42 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 10 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

Quoted 4 lines

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

It's also what pthread_cond_wait does internally, BTW.

Jan

#4 lore raw
In reply to Jan Kiszka
Quoted 42 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 10 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

Quoted 3 lines

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

if rt_cond_wait_epilogue returns an error other than -EINTR, there is an error to be signaled, so, it should be returned to the user, not 0 or -ETIMEDOUT which would let the user think that he got the mutex back, whereas the mutex is probably not properly locked.

Quoted 3 lines

Jan

Signature · 1 line
					    Gilles.
#5 lore raw
Quoted 42 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 40 lines · Gilles Chanteperdrix
Quoted 27 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 10 lines
ksrc/skins/native/cond.c +4 -4
 				    timeout_mode, timeout);
 
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

Quoted 8 lines
Quoted 3 lines

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

if rt_cond_wait_epilogue returns an error other than -EINTR, there is an error to be signaled, so, it should be returned to the user, not 0 or -ETIMEDOUT which would let the user think that he got the mutex back, whereas the mutex is probably not properly locked.

And if prologue returned -EINTR, and epilogue ran successfully, we do not want to return -EINTR to the user either.

Signature · 1 line
					    Gilles.
#6 lore raw
Quoted 46 lines · Gilles Chanteperdrix
Quoted 45 lines · Gilles Chanteperdrix
Quoted 44 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 10 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

Quoted 7 lines
Quoted 4 lines

if rt_cond_wait_epilogue returns an error other than -EINTR, there is an error to be signaled, so, it should be returned to the user, not 0 or -ETIMEDOUT which would let the user think that he got the mutex back, whereas the mutex is probably not properly locked.

And if prologue returned -EINTR, and epilogue ran successfully, we do not want to return -EINTR to the user either.

We surely want as the cond_wait did NOT succeed in that case.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#7 lore raw
Quoted 47 lines · Jan Kiszka
Quoted 46 lines · Gilles Chanteperdrix
Quoted 45 lines · Gilles Chanteperdrix
Quoted 44 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 10 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

if rt_cond_wait_epilogue returns an error other than -EINTR, there is an error to be signaled, so, it should be returned to the user, not 0 or -ETIMEDOUT which would let the user think that he got the mutex back, whereas the mutex is probably not properly locked.

And if prologue returned -EINTR, and epilogue ran successfully, we do not want to return -EINTR to the user either.

We surely want as the cond_wait did NOT succeed in that case.

No, we do not know whether it succeeded, the condition may well have been signaled while we no longer were waiting on the synch object. So, we should return 0, and let the test the user must have in his code decide whether the wakeup was spurious or not. In POSIX land, spurious condition wake-up are permitted, I bet we want the same for the rt_cond_wait interface. Which is why, BTW, all books on the pthread interface recommend to use:

while (!cond)
pthread_cond_wait

and not:

if (!cond)
pthread_cond_wait

Signature · 1 line
					    Gilles.
#8 lore raw
Quoted 65 lines · Gilles Chanteperdrix
Quoted 47 lines · Jan Kiszka
Quoted 46 lines · Gilles Chanteperdrix
Quoted 45 lines · Gilles Chanteperdrix
Quoted 44 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 10 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

if rt_cond_wait_epilogue returns an error other than -EINTR, there is an error to be signaled, so, it should be returned to the user, not 0 or -ETIMEDOUT which would let the user think that he got the mutex back, whereas the mutex is probably not properly locked.

And if prologue returned -EINTR, and epilogue ran successfully, we do not want to return -EINTR to the user either.

We surely want as the cond_wait did NOT succeed in that case.

No, we do not know whether it succeeded, the condition may well have been signaled while we no longer were waiting on the synch object. So, we should return 0, and let the test the user must have in his code decide whether the wakeup was spurious or not. In POSIX land, spurious condition wake-up are permitted, I bet we want the same for the rt_cond_wait interface. Which is why, BTW, all books on the pthread interface recommend to use:

Quoted 8 lines

while (!cond)
pthread_cond_wait

and not:

if (!cond)
pthread_cond_wait

This is not user space, this is (deprecated) kernel space. Let's not fiddle with this old interface, just restore what we had so that existing apps can rest in peace. User space is different due to signal handling anyway.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#9 lore raw
Quoted 70 lines · Jan Kiszka
Quoted 69 lines · Gilles Chanteperdrix
Quoted 47 lines · Jan Kiszka
Quoted 46 lines · Gilles Chanteperdrix
Quoted 45 lines · Gilles Chanteperdrix
Quoted 44 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 10 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

if rt_cond_wait_epilogue returns an error other than -EINTR, there is an error to be signaled, so, it should be returned to the user, not 0 or -ETIMEDOUT which would let the user think that he got the mutex back, whereas the mutex is probably not properly locked.

And if prologue returned -EINTR, and epilogue ran successfully, we do not want to return -EINTR to the user either.

We surely want as the cond_wait did NOT succeed in that case.

No, we do not know whether it succeeded, the condition may well have been signaled while we no longer were waiting on the synch object. So, we should return 0, and let the test the user must have in his code decide whether the wakeup was spurious or not. In POSIX land, spurious condition wake-up are permitted, I bet we want the same for the rt_cond_wait interface. Which is why, BTW, all books on the pthread interface recommend to use:

while (!cond)
pthread_cond_wait

and not:

Quoted 8 lines
Quoted 3 lines

if (!cond)
pthread_cond_wait

This is not user space, this is (deprecated) kernel space. Let's not fiddle with this old interface, just restore what we had so that existing apps can rest in peace. User space is different due to signal handling anyway.

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 3 lines

Jan

Signature · 1 line
					    Gilles.
#10 lore raw
Quoted 79 lines · Gilles Chanteperdrix
Quoted 70 lines · Jan Kiszka
Quoted 69 lines · Gilles Chanteperdrix
Quoted 47 lines · Jan Kiszka
Quoted 46 lines · Gilles Chanteperdrix
Quoted 45 lines · Gilles Chanteperdrix
Quoted 44 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: f1dfda551b6997f74141986759932e2723a9f024
URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f1dfda551b6997f74141986759932e2723a9f024
Author: Jan Kiszka <[email protected]>
Date:   Tue Mar  2 13:17:35 2010 +0100

Native: Fix return code of in-kernel rt_cond_wait[_until]

In rt_cond_wait_inner, do not let rt_cond_wait_epilogue overwrite the primary error code of rt_cond_wait_prologue. This restores the in-kernel semantics of rt_cond_wait[_until] that were valid before 97323b3287.

---

 ksrc/skins/native/cond.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
ksrc/skins/native/cond.c +0 -0
index 10727d1..2dc0069 100644
@@ -472,10 +472,10 @@ static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex,
 	err = rt_cond_wait_prologue(cond, mutex, &lockcnt, 
 				    timeout_mode, timeout);
 
Quoted 10 lines

ksrc/skins/native/cond.c static int rt_cond_wait_inner(RT_COND *cond, RT_MUTEX *mutex, · line 478

Quoted 8 lines
ksrc/skins/native/cond.c +4 -4
-	if(!err || err == -ETIMEDOUT || err == -EINTR)
-		do {
-			err = rt_cond_wait_epilogue(mutex, lockcnt);
-		} while (err == -EINTR);
+	if (!err || err == -ETIMEDOUT || err == -EINTR) {
+		while (rt_cond_wait_epilogue(mutex, lockcnt) == -EINTR)
+			; /* empty */
+	}

Not ok. If rt_cond_wait_epilogue returns an error other than -EINTR, we want this error to be returned.

As I said: This is what we used to do in 2.4 (and early 2.5-rc), and due to the absence of spec on this topic, I would vote for restoring old behavior.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

if rt_cond_wait_epilogue returns an error other than -EINTR, there is an error to be signaled, so, it should be returned to the user, not 0 or -ETIMEDOUT which would let the user think that he got the mutex back, whereas the mutex is probably not properly locked.

And if prologue returned -EINTR, and epilogue ran successfully, we do not want to return -EINTR to the user either.

We surely want as the cond_wait did NOT succeed in that case.

No, we do not know whether it succeeded, the condition may well have been signaled while we no longer were waiting on the synch object. So, we should return 0, and let the test the user must have in his code decide whether the wakeup was spurious or not. In POSIX land, spurious condition wake-up are permitted, I bet we want the same for the rt_cond_wait interface. Which is why, BTW, all books on the pthread interface recommend to use:

while (!cond)
pthread_cond_wait

and not:

Quoted 7 lines
Quoted 3 lines

if (!cond)
pthread_cond_wait

This is not user space, this is (deprecated) kernel space. Let's not fiddle with this old interface, just restore what we had so that existing apps can rest in peace. User space is different due to signal handling anyway.

Quoted 6 lines

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#11 lore raw
Quoted 11 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

Signature · 1 line
					    Gilles.
#12 lore raw
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 7 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#13 lore raw
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Quoted 6 lines
Quoted 3 lines

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

Signature · 1 line
					    Gilles.
#14 lore raw
Quoted 23 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

Quoted 8 lines

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

OK, but EIDRM was missing in your list. Will adjust both patches.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#15 lore raw
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

Quoted 4 lines
Quoted 2 lines

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

OK, but EIDRM was missing in your list. Will adjust both patches.

No, EIDRM is part of the "other errors than ETIMEDOUT and 0"

Signature · 1 line
					    Gilles.
#16 lore raw
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

OK, but EIDRM was missing in your list. Will adjust both patches.

No, EIDRM is part of the "other errors than ETIMEDOUT and 0"

I interpret the spec fairly differently here: It states that we have to leave the mutex state behind *as if* the error was already detected on entry - thus we are expected to restore its state.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#17 lore raw
Quoted 33 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

OK, but EIDRM was missing in your list. Will adjust both patches.

No, EIDRM is part of the "other errors than ETIMEDOUT and 0"

I interpret the spec fairly differently here: It states that we have to leave the mutex state behind *as if* the error was already detected on entry - thus we are expected to restore its state.

No. We must return prior to modifying its state. Not change its state then restore it.

There is no EIDRM anyway, I return 0, and the user gets EINVAL when calling pthread_cond_wait again.

Signature · 1 line
					    Gilles.
#18 lore raw
Quoted 35 lines · Gilles Chanteperdrix
Quoted 34 lines · Jan Kiszka
Quoted 33 lines · Gilles Chanteperdrix
Quoted 32 lines · Jan Kiszka
Quoted 22 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

Quoted 8 lines

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

OK, but EIDRM was missing in your list. Will adjust both patches.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

No, EIDRM is part of the "other errors than ETIMEDOUT and 0"

I interpret the spec fairly differently here: It states that we have to leave the mutex state behind *as if* the error was already detected on entry - thus we are expected to restore its state.

No. We must return prior to modifying its state. Not change its state then restore it.

"..., _in effect_, prior to modifying the state..."

Quoted 3 lines

There is no EIDRM anyway, I return 0, and the user gets EINVAL when calling pthread_cond_wait again.

In that case, he may get EPERM later on when trying to release the mutex he is supposed to hold after cond_wait returned 0.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#19 lore raw
Quoted 44 lines · Jan Kiszka
Quoted 34 lines · Gilles Chanteperdrix
Quoted 33 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

OK, but EIDRM was missing in your list. Will adjust both patches.

No, EIDRM is part of the "other errors than ETIMEDOUT and 0"

I interpret the spec fairly differently here: It states that we have to leave the mutex state behind *as if* the error was already detected on entry - thus we are expected to restore its state.

No. We must return prior to modifying its state. Not change its state then restore it.

Quoted 7 lines

"..., _in effect_, prior to modifying the state..."

Quoted 2 lines

There is no EIDRM anyway, I return 0, and the user gets EINVAL when calling pthread_cond_wait again.

In that case, he may get EPERM later on when trying to release the mutex he is supposed to hold after cond_wait returned 0.

He is not supposed to hold it. He holds it, because we returned 0, and when we return 0, the mutex is re-acquired.

Quoted 3 lines

Jan

Signature · 1 line
					    Gilles.
#20 lore raw
In reply to Gilles Chanteperdrix
Quoted 41 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

OK, but EIDRM was missing in your list. Will adjust both patches.

No, EIDRM is part of the "other errors than ETIMEDOUT and 0"

I interpret the spec fairly differently here: It states that we have to leave the mutex state behind *as if* the error was already detected on entry - thus we are expected to restore its state.

Quoted 5 lines

No. We must return prior to modifying its state. Not change its state then restore it.

There is no EIDRM anyway, I return 0, and the user gets EINVAL when calling pthread_cond_wait again.

No, this is not even the way it works. EIDRM can not happen, because pthread_cond_destroy will return EBUSY as long as a thread is blocked in a call to pthread_cond_wait. This is allowed by POSIX.

Quoted 1 line
Signature · 1 line
					    Gilles.
#21 lore raw
Quoted 44 lines · Gilles Chanteperdrix
Quoted 43 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

No. If the error is another error than 0, -ETIMEDOUT, or -EINTR, it means that the error was detected prior to freeing the mutex. So, we do not have to re-acquire the mutex. Quoting POSIX:

"Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond."

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

POSIX does not talk about -EINTR, because it states that in this case, we should return 0 to the application.

OK, but EIDRM was missing in your list. Will adjust both patches.

No, EIDRM is part of the "other errors than ETIMEDOUT and 0"

I interpret the spec fairly differently here: It states that we have to leave the mutex state behind *as if* the error was already detected on entry - thus we are expected to restore its state.

No. We must return prior to modifying its state. Not change its state then restore it.

Quoted 7 lines
Quoted 2 lines

There is no EIDRM anyway, I return 0, and the user gets EINVAL when calling pthread_cond_wait again.

No, this is not even the way it works. EIDRM can not happen, because pthread_cond_destroy will return EBUSY as long as a thread is blocked in a call to pthread_cond_wait. This is allowed by POSIX.

Right, POSIX is fine as is. Native is still different, though.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#22 lore raw
In reply to Jan Kiszka
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Quoted 7 lines
Quoted 3 lines

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

Was only an issue of my POSIX patch, native was not touching cond in the epilogue. Update pushed.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#23 lore raw
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Gilles Chanteperdrix
Quoted 10 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix

Ok for returning -EINTR, it is documented. Kernel-space is not so different from user-space, rt_task_unblock could wake-up a kernel-space task blocked in a call to rt_cond_wait.

However, if the epilogue returns an error, we must return it.

OK for this. Pushed an update, but I also modified it further to avoid returning without the mutex lock unless that one is also failing. Maybe in-kernel POSIX requires the same fix, will check.

Still not OK. You should reacquire the mutex only if the error is 0, -ETIMEDOUT or -EINTR. With any other error, we do not know if we can call the epilogue safely.

Quoted 6 lines
Quoted 3 lines

We _must_ reacquire the mutex - but, granted, we actually have to take care of invalid cond objects. Lot's of bugs...

Was only an issue of my POSIX patch, native was not touching cond in the epilogue. Update pushed.

Ok. I have work to do, so, will stop commenting each of your patches. But no, I will not take this one.

Signature · 1 line
					    Gilles.