PhotonLibOS
PhotonLibOS copied to clipboard
PhotonLib crashes with other thread models
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|
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
@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.
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.
What do you mean by 'async' and "experimental"?