Printer spooler and TransientSemaphore wait

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

Printer spooler and TransientSemaphore wait

GLASS mailing list

Ciao,

    in the application based on Seaside, i manage some printers devices.

Every device have a RcQueue where the system add the 'works' to print.

Besides there is a topaz script/server, which read the prints jobs and does the printing.

    Now this script is based spoolSemaphore class variable set to on TransientSemaphore,

        who waits for the presence of a new document to be reported,

segnaled when one relative entry is added to one RcQueue printer device.

This is the printerSpool script:

  startPrinterSpool
  | cllDbSpoolerActive flagLo......................  |

  UserGlobals at: #'FlagSpooler' put: true.

  spoolSemaphore := TransientSemaphore new.
 

     [ UserGlobals at: #'FlagSpooler' ]
        whileTrue: [

              spoolSemaphore  waitForSeconds: 1.
             

            System commit. " Update the session data "
            counterLimit := DTRdbOperatingDevice ticktesForCicle.

            ....................

            .............

         If in the whileTrue loop i define the:

              spoolSemaphore  waitForSeconds: 1.

        the topaz script works, but not waiting as I would like .....

If in the whileTrue loop i define the:

              spoolSemaphore  wait.

        the topaz script generates the error:

ERROR 2366 , a ThreadError occurred (error 2366), reason:rtErrSchedulerDeadlocked, The ProcessorScheduler is deadlocked (ThreadError)

 

Considerations... ?

Thanks,

Dario


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Printer spooler and TransientSemaphore wait

GLASS mailing list
Dario,

Are you intending the semaphore to work between gems? If so, then it won’t work. A semaphore is “DbTransient,” meaning that its state is not persistent in the database. A Smalltalk Semaphore works only inside a single virtual machine (Gem).

Instead, it should be sufficient for you to use GemStone’s transaction semantics. A “producer” adds and item to an RcQueue and commits, while a “consumer” periodically aborts and looks to see if the queue is non-empty. For simplicity, the consumer should have a delay in its polling loop.

James

On Jul 10, 2018, at 8:17 AM, [hidden email] via Glass <[hidden email]> wrote:

Ciao,

    in the application based on Seaside, i manage some printers devices.

Every device have a RcQueue where the system add the 'works' to print.

Besides there is a topaz script/server, which read the prints jobs and does the printing.

    Now this script is based spoolSemaphore class variable set to on TransientSemaphore,

        who waits for the presence of a new document to be reported,

segnaled when one relative entry is added to one RcQueue printer device.


This is the printerSpool script:

  startPrinterSpool
  | cllDbSpoolerActive flagLo......................  |

  UserGlobals at: #'FlagSpooler' put: true.

  spoolSemaphore := TransientSemaphore new.
 

     [ UserGlobals at: #'FlagSpooler' ]
        whileTrue: [

              spoolSemaphore  waitForSeconds: 1.
             

            System commit. " Update the session data "
            counterLimit := DTRdbOperatingDevice ticktesForCicle.

            ....................

            .............

         If in the whileTrue loop i define the:

              spoolSemaphore  waitForSeconds: 1.

        the topaz script works, but not waiting as I would like .....

If in the whileTrue loop i define the:

              spoolSemaphore  wait.

        the topaz script generates the error:

ERROR 2366 , a ThreadError occurred (error 2366), reason:rtErrSchedulerDeadlocked, The ProcessorScheduler is deadlocked (ThreadError)

 

Considerations... ?

Thanks,

Dario

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Printer spooler and TransientSemaphore wait

GLASS mailing list
Also the GemStone seaside package 'Seaside-GemStone-ServiceTask' can manage
the polling James is talking about.  It checks every 200ms for tasks to do.
The tasks are defined in the class side of WAGemStoneServiceVMTask.  See
#serviceVMTaskServiceExample for an example.

Once you add a task of your own you'd need to restart the servicevm gem.

The daemontools repo has the code to set up & run the servicevm






GLASS mailing list wrote

> Dario,
>
> Are you intending the semaphore to work between gems? If so, then it won’t
> work. A semaphore is “DbTransient,” meaning that its state is not
> persistent in the database. A Smalltalk Semaphore works only inside a
> single virtual machine (Gem).
>
> Instead, it should be sufficient for you to use GemStone’s transaction
> semantics. A “producer” adds and item to an RcQueue and commits, while a
> “consumer” periodically aborts and looks to see if the queue is non-empty.
> For simplicity, the consumer should have a delay in its polling loop.
>
> James
>
>> On Jul 10, 2018, at 8:17 AM,

> dario.trussardi@

>  via Glass &lt;

> glass@.gemtalksystems

> &gt; wrote:
>>
>> Ciao,
>>
>>     in the application based on Seaside, i manage some printers devices.
>>
>> Every device have a RcQueue where the system add the 'works' to print.
>>
>> Besides there is a topaz script/server, which read the prints jobs and
>> does the printing.
>>
>>     Now this script is based spoolSemaphore class variable set to on
>> TransientSemaphore,
>>         who waits for the presence of a new document to be reported,
>>
>> segnaled when one relative entry is added to one RcQueue printer device.
>>
>>
>>
>> This is the printerSpool script:
>>
>>   startPrinterSpool
>>   | cllDbSpoolerActive flagLo......................  |
>>
>>   UserGlobals at: #'FlagSpooler' put: true.
>>
>>   spoolSemaphore := TransientSemaphore new.
>>  
>>
>>      [ UserGlobals at: #'FlagSpooler' ]
>>         whileTrue: [
>>               spoolSemaphore  waitForSeconds: 1.
>>              
>>             System commit. " Update the session data "
>>             counterLimit := DTRdbOperatingDevice ticktesForCicle.
>>
>>             ....................
>>
>>             .............
>>          If in the whileTrue loop i define the:
>>
>>               spoolSemaphore  waitForSeconds: 1.
>>
>>         the topaz script works, but not waiting  as I would like .....
>>
>> If in the whileTrue loop i define the:
>>
>>               spoolSemaphore  wait.
>>
>>         the topaz script generates the error:
>>
>> ERROR 2366 , a ThreadError occurred (error 2366),
>> reason:rtErrSchedulerDeadlocked, The ProcessorScheduler is deadlocked
>> (ThreadError)
>>
>>  
>> Considerations... ?
>>
>> Thanks,
>>
>> Dario
>>
>> _______________________________________________
>> Glass mailing list
>>

> Glass@.gemtalksystems

>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>
>
> _______________________________________________
> Glass mailing list

> Glass@.gemtalksystems

> http://lists.gemtalksystems.com/mailman/listinfo/glass





--
Sent from: http://forum.world.st/GLASS-f1460844.html
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass