Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Read again my corrected post about coroutines

5 views
Skip to first unread message

Ramine

unread,
Aug 26, 2016, 2:03:39 PM8/26/16
to
Hello,

Read again my corrected post about coroutines

In this post i will explain to you what i have written as 64 bit
assembler routines for my Stackful coroutines
library..

But first comes first, why have i decided to implement
this assembler routines of my stackful coroutines library ?

I have decided to do it because i have learned how the operating
system saves and restores the registers and the stacks when
it works with threads , because coroutines are not far away from
threads, you can learn a lot on implementing threads by implementing
coroutines..


Now what is the important advantages of my coroutines library?

- Context switching is expensive with threads, with coroutines it is
really fast.

- Coroutines eliminate race conditions and that's really interesting
on embedded systems and other applications.

- My mutex and semaphore of my coroutines library are much much
more faster than the mutex and semaphore used on processes and threads.


Now how have i implemented it with 64 bit assembler routines?

First you have to replace the RSP and RBP registers with a pointer to
a dynamic allocated memory to be able to save the local variables
of the coroutines.

Second, you have to avoid to generate the stack frames to simplify
the implementation in assembler, this will simplify the saving
of the RBP register for example, and you have to search for the
returned IP register address with the RSP register to to be able
to return back from the yield() routine, other than that
you have to save some registers and restores them back.

You can download my Stackful coroutines library for Delphi and
FreePascal from:

https://sites.google.com/site/aminer68/stackful-coroutines-library-for-delphi-and-freepascal

You can download my Object oriented Stackful coroutines library for
Delphi and FreePascal from:

https://sites.google.com/site/aminer68/object-oriented-stackful-coroutines-library-for-delphi-and-freepascal


That's all for today.


Thank you,
Amine Moulay Ramdane.






0 new messages