Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #54720
| From | Alex <alex@rivadpm.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Really? |
| Date | 2017-02-08 13:43 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o7f76l$919$1@dont-email.me> (permalink) |
| References | (4 earlier) <puydnYi-qeSvwgfFnZ2dnUU7-dPNnZ2d@supernews.com> <01fb25bd-7975-4ca5-b9e6-1024cb772c7a@googlegroups.com> <o7eeqj$t4a$1@dont-email.me> <1207313c-ffcd-4640-a619-f1424dcf75cc@googlegroups.com> <o7el40$doe$1@dont-email.me> |
On 2/8/2017 08:34, rickman wrote:
>>>> Looking at the whole application is going to be difficult when there
>>>> is 16MB of source-code --- the programmers need to understand the
>>>> concept of re-entrancy --- they can't pass data between functions in
>>>> global variables.
>>
>>> You are aware that re-entrancy is only an issue with multitasking,
>>> right? Was this OS multitasking?
>>
>> Re-entrancy is not just an issue with multi-tasking.
>>
>> If a function uses PAD internally and calls another function that uses
>> PAD internally, then chaos will result.
>>
>> This should be obvious to anybody!
Function A setting PAD and calling B that sets PAD is a simple case of
the side effect of using global variables, specifically when they are
modified. (No-one objects to constants as globals, because they are only
ever read and not set.)
For this kind of problem, only rewriting the code will fix it, but it
definitely does not need to be reentrant.
>
> I don't know I've ever seen this referred to as reentrancy. Looking on
> the web it's hard to find authoritative sources about reentrancy... but
> here is wikipedia, not that I consider wikipedia to necessarily be
> authoritative.
>
> ********************************
> In computing, a computer program or subroutine is called reentrant if it
> can be interrupted in the middle of its execution, and then be safely
> called again ("re-entered") before its previous invocations complete
> execution. The interruption could be caused by an internal action such
> as a jump or call, or by an external action such as a hardware interrupt
> or signal. Once the reentered invocation completes, the previous
> invocations will resume correct execution.
> ********************************
It's not very good.
>
> So they do allow for the case of a routine calling another and ending up
> calling itself. But what you describe is one routine calling another
> that shares a common data structure. That's not technically reentrancy.
> Still, I suppose I get your point. Recursion is a form of reentrancy.
> But that simply means you need to be aware when routines can be called
> recursively which is very infrequent. Otherwise, you simply have to be
> aware when you are sharing data structures.
That's exactly the point. Excuse my lecture, but...
External hardware interrupts may cause key components of the OS or
application to be entered while they are executing on behalf of another
task. When multiprogramming (more than one processor), even the software
can interfere with itself. There are a few solutions.
1. Suspend interrupts while dealing with interrupts. Doesn't really
provide a solution when multiple processors are involved, since the same
code can be executed by several processors.
2. Make sure that the routines do not refer to global areas, so that
each incomplete execution is not interfered with by a new execution of
the same code. This can be problematic (we may have only 1 of a given
resource, but several tasks sharing it for example), so another
technique is used;
3. For small shared resources like counters or addresses, get the
processors to help by using atmoic operations that most provide. For
instance, the Intel x86 LOCK prefix and CMPXCHG instructions do this.
4. For larger shared resources, employ software locking or enqueuing,
where tasks will wait for shared resources to be free. Tasks that can
get the lock proceed and then release it; tasks that can't, wait until
the lock is released. This generally requires atomic operations to
accomplish.
Back to Hugh's comments about passing data via global variables making
code non-reentrant.
: increment ( addr -- ) dup @ 1+ swap ! ; \ increment value at address
Even though INCREMENT does not itself refer to global variables and
appears at first sight to be reentrant, two tasks using the shared area
SHARED invoking SHARED INCREMENT will give inconsistent results when
SHARED is fetched.
--
Alex
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Really? Mark Wills <markwills1970@gmail.com> - 2017-02-06 06:46 -0800
Re: Really? foxaudioresearch@gmail.com - 2017-02-06 07:20 -0800
Re: Really? polymorph self <jackvanc3@gmail.com> - 2017-02-06 08:58 -0800
Re: Really? rickman <gnuarm@gmail.com> - 2017-02-06 13:06 -0500
Re: Really? hughaguilar96@gmail.com - 2017-02-06 11:25 -0800
Re: Really? "HAA" <someone@microsoft.com> - 2017-02-07 11:45 +1100
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-06 15:38 -1000
Re: Really? hughaguilar96@gmail.com - 2017-02-07 09:50 -0800
Re: Really? Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-02-06 23:39 -0500
Re: Really? Mark Wills <markwills1970@gmail.com> - 2017-02-07 08:04 -0800
Re: Really? "HAA" <someone@microsoft.com> - 2017-02-08 11:04 +1100
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 23:42 -0800
Re: Really? "HAA" <someone@microsoft.com> - 2017-02-08 20:12 +1100
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-08 02:44 -0800
Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-08 17:48 +0000
Re: Really? Alex <alex@rivadpm.com> - 2017-02-08 18:43 +0000
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-08 15:24 -0800
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-08 16:26 -0800
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 22:45 -0800
Re: Really? hughaguilar96@gmail.com - 2017-02-07 22:50 -0800
Re: Really? clozaga@gmail.com - 2017-02-08 21:03 -0800
Re: Really? clozaga@gmail.com - 2017-02-08 21:04 -0800
Re: Really? hughaguilar96@gmail.com - 2017-02-11 20:01 -0800
Re: Really? Alex <alex@rivadpm.com> - 2017-02-12 16:26 +0000
Re: Really? hughaguilar96@gmail.com - 2017-02-12 16:52 -0800
Re: Really? Alex <alex@rivadpm.com> - 2017-02-13 09:49 +0000
Re: Really? minforth@arcor.de - 2017-02-13 07:03 -0800
Re: Really? hughaguilar96@gmail.com - 2017-02-13 13:41 -0800
Re: Really? Alex <alex@rivadpm.com> - 2017-02-13 22:32 +0000
Re: Really? hughaguilar96@gmail.com - 2017-02-15 11:42 -0800
Re: Really? Alex <alex@rivadpm.com> - 2017-02-15 20:41 +0000
Re: Really? hughaguilar96@gmail.com - 2017-02-17 09:42 -0800
Re: Really? Alex <alex@rivadpm.com> - 2017-02-17 22:22 +0000
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-12 19:24 -1000
Re: Really? Alex <alex@rivadpm.com> - 2017-02-13 08:49 +0000
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-07 11:01 +0000
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 03:06 -0800
Re: Really? hughaguilar96@gmail.com - 2017-02-07 09:35 -0800
Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-07 17:35 +0000
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 23:24 -0800
Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-09 08:57 +0000
Re: Really? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-09 13:24 +0100
Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-11 15:32 +0000
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-07 20:42 +0000
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-07 13:58 -1000
Re: Really? hughaguilar96@gmail.com - 2017-02-07 21:51 -0800
Re: Really? rickman <gnuarm@gmail.com> - 2017-02-08 01:47 -0500
Re: Really? hughaguilar96@gmail.com - 2017-02-07 22:52 -0800
Re: Really? rickman <gnuarm@gmail.com> - 2017-02-08 03:34 -0500
Re: Really? Alex <alex@rivadpm.com> - 2017-02-08 13:43 +0000
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-08 15:39 -1000
Re: Really? hughaguilar96@gmail.com - 2017-02-08 22:39 -0800
Re: Really? Alex <alex@rivadpm.com> - 2017-02-09 08:56 +0000
Re: Really? hughaguilar96@gmail.com - 2017-02-09 14:36 -0800
Re: Really? Alex <alex@rivadpm.com> - 2017-02-10 08:33 +0000
Re: Really? Alex <alex@rivadpm.com> - 2017-02-09 09:03 +0000
Re: Really? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-09 10:51 +0100
Re: Really? john <anon@example.com> - 2017-02-09 11:54 +0000
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-09 09:30 -1000
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-09 14:14 +0000
Re: Really? Alex <alex@rivadpm.com> - 2017-02-09 14:37 +0000
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-09 15:24 +0000
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-09 12:01 -0800
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-10 01:09 +0000
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-09 18:19 -0800
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-09 16:30 -1000
Re: Really? hughaguilar96@gmail.com - 2017-02-09 19:16 -0800
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-10 16:29 +0000
OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 17:30 +0000
Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 11:46 -0600
Re: OT: [ was re: Really?] Foreign aid Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-02-10 11:54 -0600
Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 18:05 +0000
Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 17:55 +0000
Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 12:04 -0600
Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 18:07 +0000
Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 12:57 -0600
Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 19:26 +0000
Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 14:04 -0600
Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-11 09:35 +0000
Re: Really? hughaguilar96@gmail.com - 2017-02-10 16:33 -0800
Static type checking (was: Really?) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-10 11:07 +0000
Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-11 15:16 +0000
Re: Really? Cecil Bayona <cbayona@cbayona.com> - 2017-02-11 10:20 -0600
Re: Really? hughaguilar96@gmail.com - 2017-02-11 19:02 -0800
Re: Really? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-10 17:31 +0100
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-08 15:34 -1000
Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-07 21:15 -1000
Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 23:46 -0800
Re: Really? hughaguilar96@gmail.com - 2017-02-07 22:47 -0800
Re: Really? Ron Aaron <rambamist@gmail.com> - 2017-02-08 08:52 +0200
Re: Really? rickman <gnuarm@gmail.com> - 2017-02-07 06:29 -0500
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-07 20:47 +0000
Re: Really? rickman <gnuarm@gmail.com> - 2017-02-07 16:23 -0500
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-08 09:47 +0000
Re: Really? rickman <gnuarm@gmail.com> - 2017-02-08 05:13 -0500
Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-08 11:23 +0000
Re: Really? Cecil Bayona <cbayona@cbayona.com> - 2017-02-07 09:49 -0600
Really? Mark Wills <markwills1970@gmail.com> - 2017-02-09 00:30 -0800
Re: Really? "HAA" <someone@microsoft.com> - 2017-02-10 10:32 +1100
Re: Really? hughaguilar96@gmail.com - 2017-02-09 17:22 -0800
csiph-web