On 10/25/23, Nathan Hartman <hartman.nat...@gmail.com> wrote:
> On Wed, Oct 25, 2023 at 5:16 AM Ville Juven <ville.ju...@gmail.com> wrote:
>
>> Hi all,
>>
>> I noticed that when spawning a new task/process from a file in
>> nsh_fileapps, the scheduler is locked prior to calling posix_spawn(),
>> which
>> does the file loading into memory etc.
>>
>> I noticed one issue with this; when the file size is large (in the order
>> of
>> MB) the scheduler is locked for very long periods at a time, in the order
>> of hundreds of milliseconds.
>
>
>
> This sounds like a bug. The scheduler should not be locked during IO-bound
> operations, since there is no way to know how long they will take. Loading
> from flash could take hundreds of milliseconds (which is already terrible)
> but imagine a different scenario where loading from a network with
> connection problems outside of the device could lock the device for many
> seconds!
>

If I understood this comment correctly:

  /* Lock the scheduler in an attempt to prevent the application from
   * running until waitpid() has been called.
   */

then maybe instead of forcing a sched_lock() we could change the
task_state to TSTATE_TASK_INACTIVE or some other that prevent the task
to be scheduled again before the posix_spawnp() get finished.

BR,

Alan

Reply via email to