Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Why not provide a standard non-busy waiting method?

Reply
Thread Tools

Why not provide a standard non-busy waiting method?

 
 
Kelsey Bjarnason
Guest
Posts: n/a
 
      02-25-2008
On Fri, 22 Feb 2008 20:16:58 -0500, CBFalconer wrote:

> mike3 wrote:
>>
>> Busy-waiting is a known anti-pattern that should be avoided. However,
>> in C, there is no standard alternative, so when a wait is required and
>> it's not busy, the program becomes 100% non-portable. So then why not
>> include this type of non-busy wait functionality in the standard?

>
> Sure, just as soon as you describe to us a sure-fire positive method of
> so doing on all the types of systems on which C runs. Note the word
> 'all'.


You have just eliminated the C standard library, at least significant
portions of it, as your "all" requirement there can't apply to them.
When will we be seeing the TC which eliminates all such functions from
the language?

Or maybe, just maybe, that "all" notion of yours is just a tired old red
herring?

 
Reply With Quote
 
 
 
 
Kenneth Brody
Guest
Posts: n/a
 
      02-25-2008
Kenny McCormack wrote:
>
> In article <(E-Mail Removed)>,
> Kenneth Brody <(E-Mail Removed)> wrote:
> >mike3 wrote:
> >>
> >> Hi.
> >>
> >> Busy-waiting is a known anti-pattern that should be avoided. However,
> >> in C, there is no standard alternative, so when a wait is required
> >> and it's not busy, the program becomes 100% non-portable. So then why
> >> not include this type of non-busy wait functionality in the standard?

> >
> >What if the underlying platform has no such support? (eg: MS-DOS.)
> >
> >Not to mention, the concept of "non-busy waiting" implies a mutli-
> >tasking system.

>
> Anyone with couple of brain cells to rub together could see that the
> way to handle this is to allow the function to be a no-op if necessary.


One could say the same thing about functions to create a subdirectory,
open a socket, or draw a circle.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <(E-Mail Removed)>


 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      02-25-2008
In article <(E-Mail Removed)>,
Kelsey Bjarnason <(E-Mail Removed)> wrote:
>On Fri, 22 Feb 2008 20:16:58 -0500, CBFalconer wrote:
>
>> mike3 wrote:
>>>
>>> Busy-waiting is a known anti-pattern that should be avoided. However,
>>> in C, there is no standard alternative, so when a wait is required and
>>> it's not busy, the program becomes 100% non-portable. So then why not
>>> include this type of non-busy wait functionality in the standard?

>>
>> Sure, just as soon as you describe to us a sure-fire positive method of
>> so doing on all the types of systems on which C runs. Note the word
>> 'all'.

>
>You have just eliminated the C standard library, at least significant
>portions of it, as your "all" requirement there can't apply to them.
>When will we be seeing the TC which eliminates all such functions from
>the language?
>
>Or maybe, just maybe, that "all" notion of yours is just a tired old red
>herring?
>


CBF is just a tired old red herring.

 
Reply With Quote
 
Kenny McCormack
Guest
Posts: n/a
 
      02-25-2008
In article <(E-Mail Removed)>,
Kelsey Bjarnason <(E-Mail Removed)> wrote:
>On Fri, 22 Feb 2008 17:18:51 -0500, Kenneth Brody wrote:
>
>> mike3 wrote:
>>>
>>> Hi.
>>>
>>> Busy-waiting is a known anti-pattern that should be avoided. However,
>>> in C, there is no standard alternative, so when a wait is required and
>>> it's not busy, the program becomes 100% non-portable. So then why not
>>> include this type of non-busy wait functionality in the standard?

>>
>> What if the underlying platform has no such support? (eg: MS-DOS.)

>
>Then it can just as readily be a busy loop. The whole point to a non-
>busy loop is to allow other processes to run; if there are no processes,
>a simple busy loop will suffice.
>


To be thoroughly, revoltingly pedantic (i.e., the norm for the group),
one should point out that if I were running MSDOS on a current laptop,
that laptop would have facilities to shut down (or slow down) the CPU to
save power and reduce wear (i.e., heat buildup) on the CPU. It can't do
this if the program busy-loops.

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      02-25-2008
Kelsey Bjarnason wrote:
> CBFalconer wrote:
>> mike3 wrote:
>>>
>>> Busy-waiting is a known anti-pattern that should be avoided.
>>> However, in C, there is no standard alternative, so when a wait
>>> is required and it's not busy, the program becomes 100%
>>> non-portable. So then why not include this type of non-busy
>>> wait functionality in the standard?

>>
>> Sure, just as soon as you describe to us a sure-fire positive
>> method of so doing on all the types of systems on which C runs.
>> Note the word 'all'.

>
> You have just eliminated the C standard library, at least
> significant portions of it, as your "all" requirement there
> can't apply to them. When will we be seeing the TC which
> eliminates all such functions from the language?
>
> Or maybe, just maybe, that "all" notion of yours is just a
> tired old red herring?


Or, maybe, you should consider it as indicating the difficulty of
providing a portable generalized substitute for busy waiting?

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      02-26-2008
CBFalconer wrote:
>
> Or, maybe, you should consider it as indicating the difficulty of
> providing a portable generalized substitute for busy waiting?


I have to remind you that C++03 already offers such a facility, as I
posted in another message of mine.

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      02-26-2008
Ioannis Vranos wrote:
> CBFalconer wrote:
>
>> Or, maybe, you should consider it as indicating the difficulty of
>> providing a portable generalized substitute for busy waiting?

>
> I have to remind you that C++03 already offers such a facility,
> as I posted in another message of mine.


C++ is a different languages, requiring different support, etc. We
can implement full C95 on a Z80, including all the minimum values.
By cutting those values we can implement C99 on the same machine
running standard CP/M. You can't do that with C++. That's one
reason why there is a separate newsgroup for it.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      02-26-2008
CBFalconer <(E-Mail Removed)> writes:
> Kelsey Bjarnason wrote:
>> CBFalconer wrote:
>>> mike3 wrote:
>>>> Busy-waiting is a known anti-pattern that should be avoided.
>>>> However, in C, there is no standard alternative, so when a wait
>>>> is required and it's not busy, the program becomes 100%
>>>> non-portable. So then why not include this type of non-busy
>>>> wait functionality in the standard?
>>>
>>> Sure, just as soon as you describe to us a sure-fire positive
>>> method of so doing on all the types of systems on which C runs.
>>> Note the word 'all'.

>>
>> You have just eliminated the C standard library, at least
>> significant portions of it, as your "all" requirement there
>> can't apply to them. When will we be seeing the TC which
>> eliminates all such functions from the language?
>>
>> Or maybe, just maybe, that "all" notion of yours is just a
>> tired old red herring?

>
> Or, maybe, you should consider it as indicating the difficulty of
> providing a portable generalized substitute for busy waiting?


Name one system with a hosted C implementation that doesn't have a
straightforward way of doing a non-busy wait. POSIX systems have
sleep(); other systems, I'm sure, have something similar.

If the sleep() function or something like it were required by the C
standard, I don't believe there would be any more difficulty in
implementing it than there has been in implementing the standard
time() function. There were other reasons, right or wrong, not to
include such a function in the standad.

--
Keith Thompson (The_Other_Keith) <(E-Mail Removed)>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      02-26-2008
Keith Thompson said:

<snip>

> Name one system with a hosted C implementation that doesn't have a
> straightforward way of doing a non-busy wait.


MS-DOS (unless you count TSRs, which should almost certainly count as
cheating).

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      02-26-2008
Richard Heathfield wrote:

> Keith Thompson said:
>
> <snip>
>
>> Name one system with a hosted C implementation that doesn't have a
>> straightforward way of doing a non-busy wait.

>
> MS-DOS (unless you count TSRs, which should almost certainly count as
> cheating).


<OT>

I think that there is nothing that potentially prevents a DOS system
from implementing a non-busy wait.

A call to sleep would invoke a system routine that would put the CPU to
sleep (using the HLT instruction), to be woken by the next clock
interrupt. The routine would of course examine the countdown timer and
keep calling HLT until the requested time period has elapsed.

</OT>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
acnt.com provide 2000 new computer hardware products. we provide most powerful computers on the market at reasonable prices. victoria Computer Information 0 10-11-2007 04:25 AM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Why the C committee doesn't provide an implementation when the standard is published? lovecreatesbeauty C Programming 52 06-14-2006 06:57 PM
why doen't sun mycrosystem provide signatures of their main dev files? onetitfemme Java 4 10-18-2005 12:52 AM



Advertisments