If your web server CRASHES, that is a serious problem that you can not address with priority fiddling. Find the root cause for the crash and fix it.
What you possibly really mean is that the server gets starved and therefore becomes unresponsive.
Yes, that can happen, and there is not a whole lot you can do about it if your target is ressource limited. You need to weigh off functionality vs. configurability. Note also that security may also be affected as there may be denial of service attacks onto your device that may effictively starve your entire system if you run the server under high priority.
There may be an error in the translation from my âPortugueseâ to English (I use Google Translate).
When I say that my system âcrashesâ it is not exactly a âcrashâ.
It becomes slow, takes a long time to respond, and pages load poorly. I solved this problem by increasing the priority of the task, which made everything work perfectly.
However, the webserver remains at a high priority all the time.
Which is not exactly a desire on my part.
Thatâs why Iâm eager to implement this change of priority.
If your web server is idle most of the time, it can not starve the rest of your system while no client is attached (unless you coded your server hapharzedly), so you will not benefit from raising the priority once a client is attached.
If your problem is that the server starves the rest of the system while there is a client session, you will not gain anything by bumping the priority with an active client session.
Dynamic priority adjustment of threads is perfectly legitimate in itself, but - just like everything else - has its place and needs to be applied where appropriate and useful.
No, the web server task is dormant until a client attaches, ie the web server is suspended on a call to attach() - at least if you follow the âstandardâ coding scheme. In that state, its priority is irrelevant as it is suspended.
Neither nor, it is the way TCP servers are generally coded. If your web server was provided by prefabbed code in your IDE, you may want to look at the generated code to see how it behaves; maybe your tool vendor does things differently to make the web server task fit better into their framework. But generally a TCP server task should not consume any significant CPU time as long as there is not client attached.
But again, just because there is no one actively using the Web UI does not mean there is no client attached. DoS attacks is one frequent problem for carelessly written Web servers; another one may be network management systems that (legitemately or in bad intentions) probe each device in the given net for listening TCP ports. So your server may be invoked more frequently than you like to know.
first of all make sure that the user authentication is sufficiently strong to prevent malicious software to get into your web server, aside from the usual recommendations. However that is not going to help if an attacker bombards your target with SYN requests on your port. Other than that, there are plenty of sites out there full of recommendations for DoS protection.
But getting back to your original question: My point was that if you indeed raise your web server taskâs priority without regard to legitimate/illegitimate connects, a DOS attacker could not only disrupt your service but also starve your target in total, so IF you follow a priority bumping strategy, make sure to raise the priority only after successfull authentication.
To build on top of what @RAc stated - which was very good. You donât want to have a TCP task âbusy loopingâ in FreeRTOS. Thias will starve the FreeRTOS Idle task from execution which is not recommened. Instead, have your task be âdormantâ which can either be âsuspendedâ or âblockedâ from the viewpoint of the FreeRTOS-Kernel (Iâd probably prefer suspended). When a client attaches you unsuspend/unblock the task and let it perform itâs work. At the end of itâs work the task would suspend/block itself.
As mentioned - security is important here and youâll want robust authentication.
Really, you donât want ANY task to busy loop. Perhaps a idle priority task could busy loop with a yield in the loop. Tasks should block until they have the ability to do work.
What @richard-damon meant is that you should never have a task that never blocks. The only possible exception to that can be a task at IDLE priority which yields regularly: