Long task + short task

10 views
Skip to first unread message

tyr.b...@gmail.com

unread,
Jun 9, 2019, 6:54:49 AM6/9/19
to The Programming Language Céu
Hi,

I just discovered cue and find it has a number of interesting concepts.


I was wondering if cue could be used for the following situation.

A program which is a combination of
- a long computation that is ran infrequently (5ms duration @ 100Hz)
- a short computation that is ran frequently (1ms duration @ 500Hz).

The total computation cost does not exceed the system resources as you can see for the above program. But the long computation may violate the assumption that all computations run fast enough such that they can be considered instantly ( in particular the long computation invalidates that assumption for the short but frequent computation).

So my questions are the following :
- is my exposition correct?
- do all computations have to take less time to execute than the smallest time step in the program?
- is there a way to make this work in cue?

Thank you!
Tyr

Francisco Sant'anna

unread,
Jun 9, 2019, 7:50:44 AM6/9/19
to ceu-...@googlegroups.com
On Sun, Jun 9, 2019 at 7:54 AM <tyr.b...@gmail.com> wrote:
A program which is a combination of
- a long computation that is ran infrequently (5ms duration @ 100Hz)
- a short computation that is ran frequently (1ms duration @ 500Hz).

The total computation cost does not exceed the system resources as you can see for the above program. But the long computation may violate the assumption that all computations run fast enough such that they can be considered instantly ( in particular the long computation invalidates that assumption for the short but frequent computation).

So my questions are the following :
- is my exposition correct?

Yes.

- do all computations have to take less time to execute than the smallest time step in the program?

Yes.

- is there a way to make this work in cue?

You should consider to use "async/thread" blocks.
An "async/thread" execution is asynchronous with the rest of the program, but it cannot share memory unless you use "atomic" blocks inside it.
The underlying implementation uses POSIX Threads, so I'm assuming you'll use Linux here or you'd need to create the appropriate hooks for your system.
I have no idea about the bookkeeping costs for POSIX Threads that execute for 1-5ms.
Also, your application is only this behavior and does not rely on complex control mechanisms with "par/or", "await", etc., maybe Céu is not the best language in this case.

Here's a sketch of your specification:

par do
    loop do
        par/and do
            await 10ms; // 100Hz
        with
            await async/thread do
                // task that takes 5ms
            end
        end
    end
with
    loop do
        par/and do
            await 2ms; // 500Hz
        with
            await async/thread do
                // task that takes 1ms
            end
        end
    end
end

--
Francisco

tyr.b...@gmail.com

unread,
Jun 9, 2019, 12:08:10 PM6/9/19
to The Programming Language Céu
Thank you. It is a very elegant system. Seems easy to built more complex systems upon that! (And sorry to miss spell céu)


Reply all
Reply to author
Forward
0 new messages