The difference between OS planning and RTOS planning

Consider a function / process,

void task_fun(void) { while(1) } If this process was run on a regular PC OS, it would happily work forever. But on a mobile phone, this will surely lead to the collapse of the entire phone in a matter of minutes, when the HW watchdog timer expires and resets the system. On a PC, this process after the expiration of its scheduled time slice will be scheduled and a new runnable process will be launched.

I doubt why we do not apply the same strategy in RTOS? What is the performance constraint if such a planning policy is implemented in the RTOS?

Another doubt is that I checked the schedule() function of both my PC OS (Ubuntu) and my phone, which also runs the Linux kernel. I found that they are both almost the same. Where is the guard pen done on my phone? My assumption is that the scheduler is the one who starts the watchdog before starting the process. Can someone tell me where in the code this is done?

+7
source share
4 answers

Phone "crash" is a problem with the design of the phone or a specific OS, and not with the embedded OS or RTOS in general. This will starve tasks of lower priority (possibly including a watchdog service), which is probably happening here.

Most built-in RTOS assumes that all processes are defined during deployment by the system developer, and the design is intended to plan all processes as needed. Placing custom or third-party code in such a system may jeopardize its scheduling scheme, as in your example. I would suggest that all such processes should be run with the same low priority as everyone else, so that the scheduler with the cyclic cycle will serve the user application the same way without compromising system services.

Phone operating systems are usually RTOS, but user processes should not be run with higher priority than system processes. It is possible that such processes run higher than the watchdog service in order to protect the system from "incorrect" applications that mimic yours.

Most RTOS uses a priority scheduler (a task with a high priority starts until it finishes, quits, or is interrupted by a task or a higher-priority interrupt). Some also plan to cyclically complete tasks at the same priority level (the task starts until it finishes, exits or spends its time slice and other tasks with the same priority).

+1
source

There are several ways to implement a watchdog timer: none of them are imposed on Linux:

  • A process or thread is periodically executed to verify that vital operations are completed. If this is not the case, corrective actions are taken, for example, rebooting the machine, or reset an unpleasant component.
  • A process or thread runs continuously to absorb the extra processor time and reset the timer. If the task cannot work, the timer expires and takes corrective actions.
  • The hardware component resets the system if it is not periodically massaged; that is, the hardware timer expires.

There is nothing here that cannot be done either in RTOS or in any other multitasking operating system.

+1
source

Linux, on a desktop computer or on a mobile phone, is not RTOS. His planning policy is time-dependent.

In RTOS, scheduling is triggered by events either from the environment via ISR, or from the software itself through system calls (send messages, wait for the mutex, ...)

+1
source

In a normal OS, we have two types of processes. The user process and the kernel process. Kernel processes have time limits. However, user processes do not have time limits.

In RTOS, all processes are a Kernel process, and therefore time limits must be strictly enforced. All processes / tasks (can be used interchangeably) are based on priority, and time constraints are important for the proper operation of the system.

So, if your void task_fun (void) {while (1)} code runs forever, other higher priority tasks will starve. Consequently, the guard dog breaks up the system to indicate to the developer that the time constraints of other tasks are not being met.

For example, the GSM scheduler should run every 4.6 ms, if your task runs longer, the time limits of the GSM Scheduler task cannot be met. Therefore, the system must reboot because its goal is defeated.

Hope this helps :)

0
source

All Articles