locked
Will create_task make an app have the need to use more CPU cores to run?

    Question

  • Hi, Dear all,

    Our Windows Store App(not phone app) worked bad on any device whose CPU cores are less than 3 (for example, the log system might fail to work with no response, it just hung there). We use create_task for all async operations when needed. I do believe there would be no more than 5 tasks are running at the same (maybe less than 5). There is no clear clue to show any abnormal.

    Would you please help me on this issue? For example, will one call to create_task use one CPU core?

    Thank you very much!

    Wednesday, January 7, 2015 6:53 AM

Answers

  • When you create a task and ask it to be run, it will be assigned a thread in the thread pool. If no thread is available, it will either be put on hold, it will be assigned to an already existing thread that has some available resource or a new thread will be created for that task (depends on overall system resources).

    A single CPU core can run multiple threads through segmentation of execution. This is why your 3 core CPU can actually run many, many more  processes than its core count.

    However, if there are too many threads and the CPU cores are not fast enough to handle all of them, your system will start experiencing performance drops.

    This is true for any multithreaded environment and it is not specific to how winRT handles things. Tasks are just syntactic sugar for a threaded API.


    Sunday, January 11, 2015 9:38 AM
  • The real question to ask is what are you doing in these tasks. It's really not an issue of how many threads you fire off but what compute activity they are doing. If these threads are all very compute intensive then of course your system will be bogged down.
    Monday, January 12, 2015 5:15 PM

All replies

  • Would anybody give me any hint? Thank you very much!
    Thursday, January 8, 2015 2:08 AM
  • Hi B0L,

    Well did you test if you have more than 5 async operation at the same time on your 3 core CPU, will you CPU hung there or will the log system file to work because of some coding issue?

    Here my machine is E5-2650 8Core, as your guess, I could not even have async operation more than 8 at same time. For this purpose, I did some test but looks I can have async operation without any limitation.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 8, 2015 6:20 AM
    Moderator
  • When you create a task and ask it to be run, it will be assigned a thread in the thread pool. If no thread is available, it will either be put on hold, it will be assigned to an already existing thread that has some available resource or a new thread will be created for that task (depends on overall system resources).

    A single CPU core can run multiple threads through segmentation of execution. This is why your 3 core CPU can actually run many, many more  processes than its core count.

    However, if there are too many threads and the CPU cores are not fast enough to handle all of them, your system will start experiencing performance drops.

    This is true for any multithreaded environment and it is not specific to how winRT handles things. Tasks are just syntactic sugar for a threaded API.


    Sunday, January 11, 2015 9:38 AM
  • The real question to ask is what are you doing in these tasks. It's really not an issue of how many threads you fire off but what compute activity they are doing. If these threads are all very compute intensive then of course your system will be bogged down.
    Monday, January 12, 2015 5:15 PM