If I have a single core CPU on a TZ-enabled device and there are two processes running: one in the secure world and one in the non-secure world, is it possible to have the scheduler manage them in an pre-emptive way, such that each process gets assigned a certain time slice?
问题:
回答1:
Actually, it is possible, but only in a round about way. You can't use a single scheduler to handle the two separate tasks as they execute in completely separate execution environments. What you can do though is use the FIQ to do the time slicing for you. If you setup the FIQ to be SW exception, you can set it to trigger on a periodic basis, for instance, every 50ms. When this happens, execution will be forced into the SW and your process can run there. You can then have the process run for a specified period and then relinquish control back to the NW, resetting the FIQ timer before leaving. The NW can then run until the FIQ triggers again.
As stated, this is NOT a single scheduler handling both SW and NW processes, but it is a potential way to do what you are attempting to do. You would still need to consider other interrupts though, so bear that in mind.
回答2:
TZ normally Execute in single thread so whenever there is a request from the non secure side to run some secure application. It will go through the monitor mode and then context switch will happen from non -secure to secure world and then secure application will start execution in the secure world in one thread. So that core will be running in the secure world for that time but if any interrupt from the no sec world then execution will stop and context will switch from secure to non secure to handle the interrupt , after handling it will again switch to secure world and this time secure world can be schedule to another core.
So as answer to your question it is not possible. As of now implementation TZ runs in single core and only one core can execute that at one time.
just to more clarify if secure application need to perform some file operation (as TZ doesn't have the file system it uses some listener to non secure side to perform that action then again context switch will happen)