Skip to contentSkip to conversation

Sleep return value

Xenomai-core Bernhard Walle 2 participants 5 messages Sep 6, 2006 – Sep 9, 2006

lore
Share & tools
lore
#0 lore raw

Hello,

,----
| int rtdm_task_sleep (uint64_t delay);
| int rtdm_task_sleep_until (uint64_t wakeup_time); `----

wouldn't it make sense to return 0 on success and in error case the number of nanoseconds that are remaining to the originally requested sleep period just as the Linux sleeping function behave?

Of course that would introduce an incompatibility to current code.

Regards,
Bernhard

Signature · 2 lines
Ich denke, es gibt weltweit einen Markt für vielleicht fünf Computer.
	-- Thomas Watson, Vorsitzender von IBM (1943)
#1 lore raw
Quoted 10 lines · Bernhard Walle

Hello,

,----
| int rtdm_task_sleep (uint64_t delay);
| int rtdm_task_sleep_until (uint64_t wakeup_time); `----

wouldn't it make sense to return 0 on success and in error case the number of nanoseconds that are remaining to the originally requested sleep period just as the Linux sleeping function behave?

Do you have a use-case for this? Would you consider this as the normal scenario?

Also note that changing the return type would take away to possibility to pass the error code.

Quoted 2 lines

Of course that would introduce an incompatibility to current code.

Given a reasonably urging use-case or brokenness of the original interface, API revisions may actually take place in RTDM (see the history). But they will surely not happen without thorough considerations of pros and cons. :)

Jan

#2 lore raw

Hello,

sorry for the late reply.

Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Bernhard Walle

Hello,

,----
| int rtdm_task_sleep (uint64_t delay);
| int rtdm_task_sleep_until (uint64_t wakeup_time); `----

Quoted 6 lines
Quoted 3 lines

wouldn't it make sense to return 0 on success and in error case the number of nanoseconds that are remaining to the originally requested sleep period just as the Linux sleeping function behave?

Do you have a use-case for this? Would you consider this as the normal scenario?

I must confess that I don't have one. I just compared the Linux API with the RTDM API for that use case. I'll dig into sources of Linux drivers and see if there are reasonable use cases. But this may take some days as I'm a bit busy now.

Quoted 2 lines

Also note that changing the return type would take away to possibility to pass the error code.

Not really. You can

< 0 : error code (in this case -EPERM)
== 0 : success

Quoted 1 line

0 : remaining time

Or simple

  int rtdm_task_sleep(uint64_t delay, uint64_t *time_left);

That would make it more compatible with the current API since the user can simply replace

  ret = rtdm_task_sleep(delay);

with

  ret = rtdm_task_sleep(delay, NULL);
Quoted 6 lines
Quoted 1 line

Of course that would introduce an incompatibility to current code.

Given a reasonably urging use-case or brokenness of the original interface, API revisions may actually take place in RTDM (see the history). But they will surely not happen without thorough considerations of pros and cons. :)

Because the missing information can be easily gathered from outside, it would be only worth changing if you plan some other changes in these functions so that this can be done in one in one step.

Regards,
Bernhard

Signature · 3 lines
Bei der Eroberung des Weltraums sind zwei Probleme zu lösen: die Schwerkraft
und der Papierkrieg. Mit der Schwerkraft wären wir fertig geworden.
	-- Wernher von Braun
#3 lore raw
Quoted 47 lines · Bernhard Walle

Hello,

sorry for the late reply.

Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Bernhard Walle

Hello,

,----
| int rtdm_task_sleep (uint64_t delay);
| int rtdm_task_sleep_until (uint64_t wakeup_time); `----

Quoted 5 lines
Quoted 3 lines

wouldn't it make sense to return 0 on success and in error case the number of nanoseconds that are remaining to the originally requested sleep period just as the Linux sleeping function behave?

Do you have a use-case for this? Would you consider this as the normal scenario?

I must confess that I don't have one. I just compared the Linux API with the RTDM API for that use case. I'll dig into sources of Linux drivers and see if there are reasonable use cases. But this may take some days as I'm a bit busy now.

Quoted 2 lines

Also note that changing the return type would take away to possibility to pass the error code.

Not really. You can

< 0 : error code (in this case -EPERM)
== 0 : success

Quoted 1 line

0 : remaining time

Or simple

  int rtdm_task_sleep(uint64_t delay, uint64_t *time_left);

That would make it more compatible with the current API since the user can simply replace

  ret = rtdm_task_sleep(delay);

with

  ret = rtdm_task_sleep(delay, NULL);
Quoted 1 line
Quoted 1 line

Of course that would introduce an incompatibility to current code.

Quoted 9 lines
Quoted 4 lines

Given a reasonably urging use-case or brokenness of the original interface, API revisions may actually take place in RTDM (see the history). But they will surely not happen without thorough considerations of pros and cons. :)

Because the missing information can be easily gathered from outside, it would be only worth changing if you plan some other changes in these functions so that this can be done in one in one step.

You exactly hit the point. :->

Jan

#4 lore raw
Quoted 5 lines · Jan Kiszka
Quoted 3 lines

Because the missing information can be easily gathered from outside, it would be only worth changing if you plan some other changes in these functions so that this can be done in one in one step.

You exactly hit the point. :->

Yes, I should first think and then post.

Regards,
Bernhard

Signature · 2 lines
OpenPGP Schlüssel-ID: B69454FD (kurz) / E8951E8FB69454FD (lang)
Fingerprint: F3BE B2A7 8161 2986 ABA4  9AB9 E895 1E8F B694 54FD