PhotonLibOS icon indicating copy to clipboard operation
PhotonLibOS copied to clipboard

PhotonLib crashes with other thread models

Open aubi1kenobi opened this issue 1 year ago • 4 comments

As mentioned twice now, Photon crashes if I add another thread that is not Photon. Q1. How can I use other thread models with Photon? More specifically OMP or if I can write my own coroutines. Because so far any other thread that is not Photon, makes your platform crash (as mentioned on your github site)

2023/05/09 06:19:19|INFO |th=0000000000000000|abc.cpp:642
handleSignal - gracefully stop Session 
Segmentation fault (core dumped)

As you can see, Photon reports thread as: |th=0000000000000000|

aubi1kenobi avatar May 09 '23 16:05 aubi1kenobi

If you are writing new project, just use photon thread, don’t mix with std::thread. photon has its way to utilize multi core.

if dealing with legacy code, you probably need to provide some demo piece. photon has an executor to coordinate with std::thread

beef9999 avatar May 09 '23 18:05 beef9999

@aubi1kenobi

Writing correct parallel programs is an essential hard problem, no matter what thread lib(s) you use. And you need to be more careful when you mix multiple threading models, because it introduces additional issues regarding inter-operation compatibility. You should understand the models before mixing them.

Photon does support mixing, and photon tries to make it easier by providing (1) some basic utilities (e.g. async interface and executor to dispatch async parallel tasks to other CPU cores); and (2) cooperative scheduling of photon threads (tasks) within a same vCPU, so that they are running much more deterministically, thus reducing bugs.

As the old saying goes, there's no silver bullet in the realm of parallel, concurrent and asynchronous programming. If you are absolutely needed to mix them up, try to minimize interaction between them.

lihuiba avatar May 14 '23 03:05 lihuiba

I beg to disagree mate. I started by using the 'async' that you provide, but they do not run asynchronously. I reported it here, and you told me they are experimental, and I should use the 'thread_creatX()'.

Why don't you provide simple lines of code to show how to do it. I've exhausted the options in your samples.

Just 3/4 lines of code on how to do async jobs the photon way. Cheers.

aubi1kenobi avatar May 21 '23 01:05 aubi1kenobi

What do you mean by 'async' and "experimental"?

lihuiba avatar May 22 '23 02:05 lihuiba