[PATCH] Process creation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Process creation

Gwenaël Casaccio
Hi,

Here is a new version of the process creation, the process is put
on the right priority queue. There are no on:do: but the root context
has special attributes and ensure will be called. Also there is another
impact  if the created process is suspended or if the priority is inferior
than the current priority the current process is not yielded.

Gwen


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

0006-Fix-Process-creation-the-priority-is-correctly-set-i.patch (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Process creation

Holger Freyther
On Tue, Mar 25, 2014 at 11:33:24AM +0100, Gwenaël Casaccio wrote:


> Subject: [PATCH 6/6] Fix Process creation the priority is correctly set, if
>  the new process is suspended the current process is not yielded. Some

Please have a look at man git-commit and make your commit messages follow
it. I really don't fancy to re-write your commit messages all the time.

> +2014-03-25  Gwenael Casaccio  <[hidden email]>
> +
> + * kernel/Process.st: Change the process creation it set on the right priority queue,
> + the previous implementation sets it on a wrong priority queue.
> + * kernel/MthContext.st: Add a new MethodContext builder.
> + * kernel/SysExcept.st: ProcessBeingTerminated>>defaultHandler will execute all the ensure blocks.

Please honor the width of 80 and wrap in a more sensible way.

> +    Process class >> termination [
> +        <category: 'private'>
> +
> +        Termination isNil ifFalse: [ ^ Termination ].
> +        ^ [
> +            Termination isNil ifTrue: [ Termination := MethodContext stack: 4 flags: 6 method: UndefinedObject>>#__terminate ip: 0 sp: -1 ].
> +            Termination
> +          ] valueWithoutPreemption
> +    ]

Same comment as before? Why so complciated instead of the simple
form I proposed?


> +
>      debugger [
>   "Return the object in charge of debugging the receiver.  This always returns
>   nil unless the DebugTools package is loaded."
> @@ -367,46 +377,17 @@ can suspend themselves and resume themselves however they wish.'>
>      ]
>  
>      onBlock: aBlockClosure at: aPriority suspend: aBoolean [
> +        <category: 'private'>
> +
> +        | closure |
> +        closure := [ [ aBlockClosure value ] ensure: [ self primTerminate ] ].
> + " With the context created by  terminate  the 'ensure' blocks not
> +  evaluated. "
> +        suspendedContext := closure asContext: (self class termination) copy.
> +        priority := aPriority.
> +        self addToBeFinalized.
> +        aBoolean ifTrue: [ ^ self ].
> +        self resume
>      ]

Rename "aBoolean" to something reasonable. Your comment is badly formatted
and is missing some words. How is the "Processor yield" thing handled? It is
not needed anymore as you fixed the invairant?

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Process creation

Gwenaël Casaccio
On 25/03/2014 14:03, Holger Hans Peter Freyther wrote:

> On Tue, Mar 25, 2014 at 11:33:24AM +0100, Gwenaël Casaccio wrote:
>
>
>> Subject: [PATCH 6/6] Fix Process creation the priority is correctly set, if
>>   the new process is suspended the current process is not yielded. Some
> Please have a look at man git-commit and make your commit messages follow
> it. I really don't fancy to re-write your commit messages all the time.
>
>> +2014-03-25  Gwenael Casaccio  <[hidden email]>
>> +
>> + * kernel/Process.st: Change the process creation it set on the right priority queue,
>> + the previous implementation sets it on a wrong priority queue.
>> + * kernel/MthContext.st: Add a new MethodContext builder.
>> + * kernel/SysExcept.st: ProcessBeingTerminated>>defaultHandler will execute all the ensure blocks.
> Please honor the width of 80 and wrap in a more sensible way.
>
>> +    Process class >> termination [
>> +        <category: 'private'>
>> +
>> +        Termination isNil ifFalse: [ ^ Termination ].
>> +        ^ [
>> +            Termination isNil ifTrue: [ Termination := MethodContext stack: 4 flags: 6 method: UndefinedObject>>#__terminate ip: 0 sp: -1 ].
>> +            Termination
>> +          ] valueWithoutPreemption
>> +    ]
> Same comment as before? Why so complciated instead of the simple
> form I proposed?
It's not complicated Holger, I want to be sure to have one instance of it.

>
>
>> +
>>       debugger [
>>   "Return the object in charge of debugging the receiver.  This always returns
>>   nil unless the DebugTools package is loaded."
>> @@ -367,46 +377,17 @@ can suspend themselves and resume themselves however they wish.'>
>>       ]
>>  
>>       onBlock: aBlockClosure at: aPriority suspend: aBoolean [
>> +        <category: 'private'>
>> +
>> +        | closure |
>> +        closure := [ [ aBlockClosure value ] ensure: [ self primTerminate ] ].
>> + " With the context created by  terminate  the 'ensure' blocks not
>> +  evaluated. "
>> +        suspendedContext := closure asContext: (self class termination) copy.
>> +        priority := aPriority.
>> +        self addToBeFinalized.
>> +        aBoolean ifTrue: [ ^ self ].
>> +        self resume
>>       ]
> Rename "aBoolean" to something reasonable. Your comment is badly formatted
> and is missing some words. How is the "Processor yield" thing handled? It is
> not needed anymore as you fixed the invairant?

Processor yield is done by self resume if priority is smaller than the
active
process the new process won't be the active one.


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Process creation

Gwenaël Casaccio
In reply to this post by Holger Freyther
On 25/03/2014 14:03, Holger Hans Peter Freyther wrote:

> On Tue, Mar 25, 2014 at 11:33:24AM +0100, Gwenaël Casaccio wrote:
>
>
>> Subject: [PATCH 6/6] Fix Process creation the priority is correctly set, if
>>   the new process is suspended the current process is not yielded. Some
> Please have a look at man git-commit and make your commit messages follow
> it. I really don't fancy to re-write your commit messages all the time.
>
>> +2014-03-25  Gwenael Casaccio  <[hidden email]>
>> +
>> + * kernel/Process.st: Change the process creation it set on the right priority queue,
>> + the previous implementation sets it on a wrong priority queue.
>> + * kernel/MthContext.st: Add a new MethodContext builder.
>> + * kernel/SysExcept.st: ProcessBeingTerminated>>defaultHandler will execute all the ensure blocks.
> Please honor the width of 80 and wrap in a more sensible way.
>
>> +    Process class >> termination [
>> +        <category: 'private'>
>> +
>> +        Termination isNil ifFalse: [ ^ Termination ].
>> +        ^ [
>> +            Termination isNil ifTrue: [ Termination := MethodContext stack: 4 flags: 6 method: UndefinedObject>>#__terminate ip: 0 sp: -1 ].
>> +            Termination
>> +          ] valueWithoutPreemption
>> +    ]
> Same comment as before? Why so complciated instead of the simple
> form I proposed?
>
>
>> +
>>       debugger [
>>   "Return the object in charge of debugging the receiver.  This always returns
>>   nil unless the DebugTools package is loaded."
>> @@ -367,46 +377,17 @@ can suspend themselves and resume themselves however they wish.'>
>>       ]
>>  
>>       onBlock: aBlockClosure at: aPriority suspend: aBoolean [
>> +        <category: 'private'>
>> +
>> +        | closure |
>> +        closure := [ [ aBlockClosure value ] ensure: [ self primTerminate ] ].
>> + " With the context created by  terminate  the 'ensure' blocks not
>> +  evaluated. "
>> +        suspendedContext := closure asContext: (self class termination) copy.
>> +        priority := aPriority.
>> +        self addToBeFinalized.
>> +        aBoolean ifTrue: [ ^ self ].
>> +        self resume
>>       ]
> Rename "aBoolean" to something reasonable. Your comment is badly formatted
> and is missing some words. How is the "Processor yield" thing handled? It is
> not needed anymore as you fixed the invairant?
Hope it's better

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

0006-kernel-Change-process-creation.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Process creation

Paolo Bonzini-2
Il 25/03/2014 15:00, Gwenaël Casaccio ha scritto:

> +        <category: 'private'>
> +
> +        Termination isNil ifFalse: [ ^ Termination ].
> +        ^ [
> +            Termination isNil ifTrue: [ Termination := MethodContext
> +                                                                stack: 4
> +                                                                flags: 6
> +                                                                method: UndefinedObject>>#__terminate
> +                                                                ip: 0
> +                                                                sp: -1 ].
> +            Termination
> +          ] valueWithoutPreemption
> +    ]

Can you explain this better?  What does it have to do with #ensure:?

Also, can you just use ##( ... ) and avoid #valueWithoutPreemption?

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Process creation

Gwenaël Casaccio
On 25/03/2014 17:33, Paolo Bonzini wrote:

> Il 25/03/2014 15:00, Gwenaël Casaccio ha scritto:
>> +        <category: 'private'>
>> +
>> +        Termination isNil ifFalse: [ ^ Termination ].
>> +        ^ [
>> +            Termination isNil ifTrue: [ Termination := MethodContext
>> + stack: 4
>> + flags: 6
>> + method: UndefinedObject>>#__terminate
>> + ip: 0
>> + sp: -1 ].
>> +            Termination
>> +          ] valueWithoutPreemption
>> +    ]
>
> Can you explain this better?  What does it have to do with #ensure:?
>
> Also, can you just use ##( ... ) and avoid #valueWithoutPreemption?
>
> Paolo
I've rewritten the patch, termination is initialized in ProcessScheduler.
I need termination otherwhise the test is not working:

"Now test process interrupts"
Eval [
     s := Semaphore new.
     ([ [ false ] whileFalse: [ Processor yield ] ]
         forkAt: Processor userBackgroundPriority)
         name: 'background';
         queueInterrupt: [ (p := Processor activeProcess) printNl. s
signal ].

     s wait.
     p printNl.
     p ensureTermination.
     p printNl
]

Gwen


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

0001-Change-the-process-creation.patch (6K) Download Attachment