|
Just remember the following and you'll do fine with multi-threading:
Variables and constants aren't.
|
|
|
|
|
I'm an admittedly rookie programmer who hasn't done much with multithreading. But wouldn't a Real Time Operating system always do things in the same order? Much like a processor on a PLC? I'm here to learn, so if you have the time to answer that would be great.
|
|
|
|
|
Not if there's I/O or something involved, but otherwise, yes, it "probably" will.
The reason I say probably is because when you're dealing with multiple cores, they don't run in lockstep with one another. There's a small amount of non-determinism just in the fact that the cores keep their own schedulers and may not have started at precisely the same moment nor even work together***
*** they might synchronize with each other - it's a FreeRTOS-ESP32variant implementation detail I haven't looked into.
But that aside, there's also the issue of I/O, which when dealing with an external device, can introduce non-determinism.
In my code, I'm outputting to a serial UART, that's connected through an FTDI built bus/USB-bridge controller to a windows PC.
Any latency introduced by the PC will ripple back to the thread that's running waiting on I/O.
Real programmers use butterflies
|
|
|
|
|
|
What scheduling algorithm is being used? IIRC, FreeRTOS has multiple scheduling algorithms you can choose between, which might affect the amount of non-determinism?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hmm. The one I'm using is a variant ported to the ESP32 to use the ESP-IDF, by Espressif.
Their forums, and the FreeRTOS documentation I've encountered online both suggest that round robin is used for any thread created on the same priority level on the same scheduler (core)
This leads to starvation. The forums warn of it particularly, but so does setting different priorities, just for slightly different reasons.
There's no "salting" done in their scheduler according to any of the documentation I've encountered.
Real programmers use butterflies
|
|
|
|
|
I was under the impression that round robin scheduling would guarantee equal time for pre-emptive tasks with the same priority (presuming no higher priority task preempts them), which should mean no starvation. Guess I was under the wrong impression.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
In the case where thread A and thread B operate at the same priority, everything works until we start looking at who to unblock. It will always unblock the next thread in the round robin list. if thread A is coded where it sleeps twice for every time thread B sleeps once, I think it will lead to one of them being starved. I'm not entirely confident in that without testing it, but it's easy for me to starve a thread in the wild on this OS.
If it were me i would have stored the machine tick based timestamp on the last time the thread was unsuspended. all priorities considered equal, i would use that to determine which to wake up next, and then if further disambiguation was necessary (doubtful) it could round robin, but i don't think that's even necessary.
Real programmers use butterflies
modified 2-Mar-21 14:56pm.
|
|
|
|
|
embar.k.adero’s spate of complaints got me wondering - what is the average age of cp users?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I'm 16.
Have been for almost thirty years.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
My dad was 29 as far back as I can remember.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
About 4 years ago, I got my mother a 50th anniversary card for her 29th birthday.
Software Zen: delete this;
|
|
|
|
|
0x35 is the average age. That's 53 base10 by the way.
|
|
|
|
|
I'm currently averaging out at 32.9 (in Mars years)
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
49 here.
(Good grief, a serious answer ).
|
|
|
|
|
lol - his account has been closed.
That would make is age the square root of negative 1.
|
|
|
|
|
excuse me, i always respected you. but with that statement ... you are accurately reflecting the arrogance of the high rep members
modified 27-Mar-21 21:01pm.
|
|
|
|
|
wrote: excuse me, i always respected you. but with that statement ... you are accurately reflecting the arrogance of the high rep members
Try not to take anything or everything that is written so seriously or so literally.
|
|
|
|
|
...and his sock puppet account has also been closed.
|
|
|
|
|
And how naiv are you? Sock puppet ... lol
modified 27-Mar-21 21:01pm.
|
|
|
|
|
Turns, not very, retard...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
You're the one creating new, throw away accounts, for what ...? Those are called "sock puppet accounts".
But, yeah, call me the naive one.
|
|
|
|
|
wrote: you are accurately reflecting the arrogance of the high rep members
Good grief, I was making a joke.
And my arrogance is completely decoupled from any regards to my reputation, but my reputation is strongly coupled to my arrogance.
|
|
|
|
|
Marc Clifton wrote: lol - his account has been closed. Which strikes me as odd.
Other than his complaint the other day I haven't seen anything from him that was out of place
I'm guessing he complained for a reason too, and I can't say I haven't seen the same at times.
|
|
|
|
|
2 different comments:
#1: the account is no longer active, so it doesn't matter.
#2: I suppose the average is just the same as before. The difference is, we now are the ones with the high weight in the ponderation.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|