Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch > #31999 > unrolled thread

(Execution) Termination bit, Alternation bit.

Started by"Skybuck Flying" <skybuck2000@hotmail.com>
First post2015-12-19 18:56 +0100
Last post2015-12-22 16:46 +0100
Articles 12 — 6 participants

Back to article view | Back to comp.arch


Contents

  (Execution) Termination bit, Alternation bit. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-12-19 18:56 +0100
    Re: (Execution) Termination bit, Alternation bit. Richard Damon <Richard@Damon-Family.org> - 2015-12-19 18:18 -0500
      Re: (Execution) Termination bit, Alternation bit. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-12-20 03:03 +0100
        Re: (Execution) Termination bit, Alternation bit. Richard Damon <Richard@Damon-Family.org> - 2015-12-19 21:50 -0500
          Re: (Execution) Termination bit, Alternation bit. Jean-Marc Bourguet <jm@bourguet.org> - 2015-12-20 09:59 +0100
            Re: (Execution) Termination bit, Alternation bit. Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-20 10:44 +0100
            Re: (Execution) Termination bit, Alternation bit. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-21 16:22 +0000
          Re: (Execution) Termination bit, Alternation bit. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-12-20 12:25 +0100
            Re: (Execution) Termination bit, Alternation bit. "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-12-20 14:20 -0800
              Re: (Execution) Termination bit, Alternation bit. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-12-21 13:40 +0100
                Re: (Execution) Termination bit, Alternation bit. Richard Damon <Richard@Damon-Family.org> - 2015-12-21 08:15 -0500
                  Re: (Execution) Termination bit, Alternation bit. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-12-22 16:46 +0100

#31999 — (Execution) Termination bit, Alternation bit.

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-12-19 18:56 +0100
Subject(Execution) Termination bit, Alternation bit.
Message-ID<df0ec$56759a3e$d47876e2$54535@news.ziggo.nl>
Hello,

I'd like to see instruction execution enhanced with the following two ideas:

1. A termination bit, and a terminator pointer.
2. A alternation bit, and a alternate pointer.

The purpose of these bits is as follows:

Before a processor/core executes an instruction both bits are examined.

1. If the termination bit is set the instruction is not executed and instead 
the processor sets the instruction pointer to the termination pointer.
2. If the alternation bit is set the instruction is not executed and instead 
the processor sets the instruction pointer to the alternation pointer.

The idea behind this is support multi threading/parallelism better.

The idea is that Thread A could terminate Thread B immediately so that 
Thread B does not continue execution.
The idea is also that Thread A could influence Thread B to start executing a 
different path.

Hopefully these bits are enough for operating systems to add support for 
this. Some issues remaining could be items pushed on the stack.
Perhaps operating system can deal with that, or perhaps compiler or perhaps 
some other special instructions or software methods can be added.
Hopefully operating systems can include data structures per thread that can 
be loaded into the core, and into these bits and pointers so that it becomes 
active.
During a context switch these bits and pointers should be loaded 
accordingly.
So these two bits and these two pointers become part of the context.

I think these two features would be usefull to make multi-threading more 
responsive and faster reaction time to changes/events occuring.

(Eventually it would be nice if these low level features would end up in 
high level languages like Python ;))

Bye,
  Skybuck.










[toc] | [next] | [standalone]


#32004

FromRichard Damon <Richard@Damon-Family.org>
Date2015-12-19 18:18 -0500
Message-ID<9Bldy.3723$Bz5.1578@fx04.iad>
In reply to#31999
On 12/19/15 12:56 PM, Skybuck Flying wrote:
> Hello,
>
> I'd like to see instruction execution enhanced with the following two
> ideas:
>
> 1. A termination bit, and a terminator pointer.
> 2. A alternation bit, and a alternate pointer.
>
> The purpose of these bits is as follows:
>
> Before a processor/core executes an instruction both bits are examined.
>
> 1. If the termination bit is set the instruction is not executed and
> instead the processor sets the instruction pointer to the termination
> pointer.
> 2. If the alternation bit is set the instruction is not executed and
> instead the processor sets the instruction pointer to the alternation
> pointer.
>
> The idea behind this is support multi threading/parallelism better.
>
> The idea is that Thread A could terminate Thread B immediately so that
> Thread B does not continue execution.
> The idea is also that Thread A could influence Thread B to start
> executing a different path.
>
> Hopefully these bits are enough for operating systems to add support for
> this. Some issues remaining could be items pushed on the stack.
> Perhaps operating system can deal with that, or perhaps compiler or
> perhaps some other special instructions or software methods can be added.
> Hopefully operating systems can include data structures per thread that
> can be loaded into the core, and into these bits and pointers so that it
> becomes active.
> During a context switch these bits and pointers should be loaded
> accordingly.
> So these two bits and these two pointers become part of the context.
>
> I think these two features would be usefull to make multi-threading more
> responsive and faster reaction time to changes/events occuring.
>
> (Eventually it would be nice if these low level features would end up in
> high level languages like Python ;))
>
> Bye,
>   Skybuck.

Most multi-core processors that I know have something sort of like what 
you are describing in an inter-processor interrupt. It might not be 
quite as direct as what you are describing but pretty close.

I would also say that what you describe, if used, would actually pretty 
much destroy a lot of efficiency in multi-threaded operations. The big 
issue is that, as described, there is no way for a process to be certain 
that it will get to execute a set of 'critical' instructions together. 
Without that ability, the code is going to need to use very pessimistic 
techniques to account for the possibility that anything can be 
interrupted anywhere.

At a hardware level, it is just a small problem to be able to interrupt 
a give thread of execution. The normal issue is that the OS has problems 
being able to do this, with the problem often being that stopping a 
thread at an arbitrary time leads to a number of system stability issues.

[toc] | [prev] | [next] | [standalone]


#32005

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-12-20 03:03 +0100
Message-ID<864af$56760c5f$d47876e2$48630@news.ziggo.nl>
In reply to#32004

"Richard Damon"  wrote in message news:9Bldy.3723$Bz5.1578@fx04.iad...

On 12/19/15 12:56 PM, Skybuck Flying wrote:
> Hello,
>
> I'd like to see instruction execution enhanced with the following two
> ideas:
>
> 1. A termination bit, and a terminator pointer.
> 2. A alternation bit, and a alternate pointer.
>
> The purpose of these bits is as follows:
>
> Before a processor/core executes an instruction both bits are examined.
>
> 1. If the termination bit is set the instruction is not executed and
> instead the processor sets the instruction pointer to the termination
> pointer.
> 2. If the alternation bit is set the instruction is not executed and
> instead the processor sets the instruction pointer to the alternation
> pointer.
>
> The idea behind this is support multi threading/parallelism better.
>
> The idea is that Thread A could terminate Thread B immediately so that
> Thread B does not continue execution.
> The idea is also that Thread A could influence Thread B to start
> executing a different path.
>
> Hopefully these bits are enough for operating systems to add support for
> this. Some issues remaining could be items pushed on the stack.
> Perhaps operating system can deal with that, or perhaps compiler or
> perhaps some other special instructions or software methods can be added.
> Hopefully operating systems can include data structures per thread that
> can be loaded into the core, and into these bits and pointers so that it
> becomes active.
> During a context switch these bits and pointers should be loaded
> accordingly.
> So these two bits and these two pointers become part of the context.
>
> I think these two features would be usefull to make multi-threading more
> responsive and faster reaction time to changes/events occuring.
>
> (Eventually it would be nice if these low level features would end up in
> high level languages like Python ;))
>
> Bye,
>   Skybuck.

"
Most multi-core processors that I know have something sort of like what
you are describing in an inter-processor interrupt. It might not be
quite as direct as what you are describing but pretty close.
"

It could be usefull if the instruction pointer/return address that was 
pushed onto the stack when the interrupt handler was called can be modified 
by the interrupt handler so that when it returns the modified instruction 
pointer is popped from the stack.

This would assume:

1. To be interrupted processor pushed it's own instruction pointer onto the 
stack.
2. To be interrupted processor pops it's own instruction pointer from stack.

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#32006

FromRichard Damon <Richard@Damon-Family.org>
Date2015-12-19 21:50 -0500
Message-ID<QHody.3724$Bz5.3354@fx04.iad>
In reply to#32005
On 12/19/15 9:03 PM, Skybuck Flying wrote:

> It could be usefull if the instruction pointer/return address that was
> pushed onto the stack when the interrupt handler was called can be
> modified by the interrupt handler so that when it returns the modified
> instruction pointer is popped from the stack.
>
> This would assume:
>
> 1. To be interrupted processor pushed it's own instruction pointer onto
> the stack.
> 2. To be interrupted processor pops it's own instruction pointer from
> stack.
>
> Bye,
>   Skybuck.

It would be an unusual machine where you couldn't modify the return 
address on the stack to change the address you return to.

[toc] | [prev] | [next] | [standalone]


#32009

FromJean-Marc Bourguet <jm@bourguet.org>
Date2015-12-20 09:59 +0100
Message-ID<87h9jd5wd7.fsf@news.bourguet.org>
In reply to#32006
Richard Damon <Richard@Damon-Family.org> writes:

> It would be an unusual machine where you couldn't modify the return address
> on the stack to change the address you return to.

Doesn't that mess up branch prediction nowadays?

Yours,

-- 
Jean-Marc

[toc] | [prev] | [next] | [standalone]


#32010

FromTerje Mathisen <terje.mathisen@tmsw.no>
Date2015-12-20 10:44 +0100
Message-ID<n55t9u$5nt$1@speranza.aioe.org>
In reply to#32009
Jean-Marc Bourguet wrote:
> Richard Damon <Richard@Damon-Family.org> writes:
>
>> It would be an unusual machine where you couldn't modify the return address
>> on the stack to change the address you return to.
>
> Doesn't that mess up branch prediction nowadays?
>
The return stack predictor is often separate from the regular branch 
predictor, and by the time you need to play these sorts of tricks in 
order to return somewhere else, flushing (part of) the return stack 
predictor tables is probably the least of your worries, right?

Terje

-- 
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

[toc] | [prev] | [next] | [standalone]


#32054

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2015-12-21 16:22 +0000
Message-ID<2015Dec21.172230@mips.complang.tuwien.ac.at>
In reply to#32009
Jean-Marc Bourguet <jm@bourguet.org> writes:
>Richard Damon <Richard@Damon-Family.org> writes:
>
>> It would be an unusual machine where you couldn't modify the return address
>> on the stack to change the address you return to.
>
>Doesn't that mess up branch prediction nowadays?

Yes, but the idea is to change the control flow of another thread,
which is going to mess up the return-stack branch prediction anyway.
Also changing memory in another core's cache is going to have a cost
of the same order as a branch misprediction or more; ok, you could be
lucky and it could be another thread on the same core, but in general
that operation is going to cost quite a bit.

- anton
-- 
M. Anton Ertl                    Some things have to be seen to be believed
anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html

[toc] | [prev] | [next] | [standalone]


#32016

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-12-20 12:25 +0100
Message-ID<d8c28$56769027$d47876e2$58902@news.ziggo.nl>
In reply to#32006

"Richard Damon"  wrote in message news:QHody.3724$Bz5.3354@fx04.iad...

On 12/19/15 9:03 PM, Skybuck Flying wrote:

> It could be usefull if the instruction pointer/return address that was
> pushed onto the stack when the interrupt handler was called can be
> modified by the interrupt handler so that when it returns the modified
> instruction pointer is popped from the stack.
>
> This would assume:
>
> 1. To be interrupted processor pushed it's own instruction pointer onto
> the stack.
> 2. To be interrupted processor pops it's own instruction pointer from
> stack.
>
> Bye,
>   Skybuck.

"
It would be an unusual machine where you couldn't modify the return
address on the stack to change the address you return to.
"

This does make me wonder how Windows 7 terminates threads/processes/hanging 
applications.

Apperently there is some kind of mechanism for this.

Perhaps it's not fully exposed to application developers or perhaps in a 
somewhat more complex way via all kinds of APIs ?

An example of how to terminate threads/processes instantly on Windows 7 
could be interesting.

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#32031

From"Chris M. Thomasson" <nospam@nospam.nospam>
Date2015-12-20 14:20 -0800
Message-ID<n579ju$boh$2@speranza.aioe.org>
In reply to#32016
> "Skybuck Flying"  wrote in message 
> news:d8c28$56769027$d47876e2$58902@news.ziggo.nl... wrote:

[...]

> This does make me wonder how Windows 7 terminates 
> threads/processes/hanging applications.

> Apperently there is some kind of mechanism for this.

Take a look at the (pthread_cancel()) function wrt async in:

https://www.sourceware.org/pthreads-win32/

IIRC, they use a special diver to queue a kernel mode APC for cancellation.

I think they fall back to Suspend/ResumeThread API if the driver is not 
present. 

[toc] | [prev] | [next] | [standalone]


#32041

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-12-21 13:40 +0100
Message-ID<f0986$5677f334$d47876e2$26800@news.ziggo.nl>
In reply to#32031
The original idea I posted is less about sending a signal to another 
processor.

It is more about how to break out of an instruction sequence.

Example of problem:

Main:
while Condition1 do
begin
    while Condition2 do
    begin
        while Condition3 do
        begin
            Routine1
        end
    end;
end;

Routine1:

while Condition4 do
begin
    while Condition5 do
    begin
        Routine2:
    end;
end;

Routine2:

while Condition6 do
begin
    while Condition7 do
    begin

    end;
end;

Breaking out of these kinds of loops, routines, code currently requires 
something like:

Current cumbersome solution for problem:

Main:
while Condition1 and not Terminated do
begin
    while Condition2 and not Terminated do
    begin
        while Condition3 and not Terminated do
        begin
            Routine1
        end
    end;
end;

Routine1:

while Condition4 and not Terminated do
begin
    while Condition5 and not Terminated do
    begin
        Routine2:
    end;
end;

Routine2:

while Condition6 and not Terminated do
begin
    while Condition7 and not Terminated do
    begin

    end;
end;

It can take a long while before all this code exits, plus the Terminated 
boolean is probably placed on wrong side.

It should be on the left side in case the Conditions are actual functions 
otherwise those would unnecessarily be executed as well.

Having something that can immediatly exit all of this code would be a nice 
feature to have.

Perhaps something like an exception block, perhaps it could be called a 
termination block.

Routine1:
Result = False

Execute
    while True do
    begin

    end;
    Result = True
Termination
    OnTerminate:
    begin

    end;
end;

return Result

Preferrably , optionally this can be omitted/left out.

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#32043

FromRichard Damon <Richard@Damon-Family.org>
Date2015-12-21 08:15 -0500
Message-ID<QXSdy.6634$QG6.5135@fx31.iad>
In reply to#32041
On 12/21/15 7:40 AM, Skybuck Flying wrote:
> The original idea I posted is less about sending a signal to another
> processor.
>
> It is more about how to break out of an instruction sequence.
>
> Example of problem:
[snip]
> Bye,
>   Skybuck.

The issue is that if your threads are doing real work, the cleanup 
needed at each point keep the environment clean for other threads likely 
varies. Just arbitrarily stopping or blindly going off to something else 
is very apt to create problems.

Some languages can be better at automatically cleaning up for you, these 
will tend to be languages that support some form of exception 
processing, as that tends to need similar support. You abort can be 
treated as a type of exception that is automatically thrown when signaled.

The problem here is that most programs, while they can handle exceptions 
in many spots, have some spots where exceptions will cause problems, 
especially in code that is directly managing the resources. Thus, you 
still need to have some definition of where to check for the breaks.

[toc] | [prev] | [next] | [standalone]


#32092

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-12-22 16:46 +0100
Message-ID<a0e83$56797053$d47876e2$15662@news.ziggo.nl>
In reply to#32043

"Richard Damon"  wrote in message news:QXSdy.6634$QG6.5135@fx31.iad...

On 12/21/15 7:40 AM, Skybuck Flying wrote:
> The original idea I posted is less about sending a signal to another
> processor.
>
> It is more about how to break out of an instruction sequence.
>
> Example of problem:
[snip]
> Bye,
>   Skybuck.

"
The issue is that if your threads are doing real work, the cleanup
needed at each point keep the environment clean for other threads likely
varies. Just arbitrarily stopping or blindly going off to something else
is very apt to create problems.

Some languages can be better at automatically cleaning up for you, these
will tend to be languages that support some form of exception
processing, as that tends to need similar support. You abort can be
treated as a type of exception that is automatically thrown when signaled.

The problem here is that most programs, while they can handle exceptions
in many spots, have some spots where exceptions will cause problems,
especially in code that is directly managing the resources. Thus, you
still need to have some definition of where to check for the breaks.
"

I can imagine that arbitrarily terminating somewhere can lead to problems 
for example in memory clean up code, where then memory leaks might occur.

Though applications do sometimes seem to clean up anyway.

One idea which immediatly comes to mind to fix this problem is to offer a 
"PushTerminationFlag" onto stack and then a "ClearTerminationFlag" 
instruction.

Then a code section can be executed without breaking or terminating.

Once that's done the code would then call "PopTerminationFlag".

At least this offers some protection against arbitrarely breaking code 
sections.

Bye,
  Skybuck.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.arch


csiph-web