• Portada
    • Recientes
    • Usuarios
    • Registrarse
    • Conectarse

    Run 2 threads on a processor with HT

    Programado Fijo Cerrado Movido Procesadores, placas base y memorias
    4 Mensajes 2 Posters 1.2k Visitas 1 Watching
    Cargando más mensajes
    • Más antiguo a más nuevo
    • Más nuevo a más antiguo
    • Mayor número de Votos
    Responder
    • Responder como tema
    Accede para responder
    Este tema ha sido borrado. Solo los usuarios que tengan privilegios de administración de temas pueden verlo.
    • cobitoC Desconectado
      cobito Administrador
      Última edición por

      Hello. I have a dual-core PC with HT and I have a question about process management. If I run a program that launches two threads of execution, is it possible that those two threads are running on a single core? That is, that they are coincidentally using two logical "cores" corresponding to a physical core.

      Uses Windows 7.

      Thanks.

      Toda la actualidad en la portada de Hardlimit
      Mis cacharros

      hlbm signature

      Bm4nB 1 Respuesta Última respuesta Responder Citar 0
      • Bm4nB Desconectado
        Bm4n @cobito
        Última edición por Bm4n

        @cobito in my opinion it depends on the workload, the OS balances the load as it sees fit. There is order but today if there are 100 threads of execution running simultaneously it is something quite random that keeps rotating as it is being processed. There are options that have to do with priority and affinity that give that order and can also be adjusted manually from the task manager. Background tasks will not have high priority and will be executed in the free slots while others with high priority occupy more cycles per second and are processed faster.

        The thing is that putting the hypothetical that the processor only had two threads to process they would surely go to core0 and core1 which correspond to the two physical cores and would be using 70% of the processor (100% would only be achieved with 4 threads to use HT). Now if there are more threads to process these will go to the queue and will automatically go to where there is a "gap" which can be physical cores or not, and once that instruction is ready the next one goes to the queue and goes to the next gap etc. etc. and so it would be random where the instruction is being processed. Now I understand that for a processor not to use one of its cores would only happen in very short fractions of time when there is a very low processing load.

        hlbm signature
        ↳ Mis componentes

        cobitoC 1 Respuesta Última respuesta Responder Citar 1
        • cobitoC Desconectado
          cobito Administrador @Bm4n
          Última edición por cobito

          @bm4n In the scenario, only half of the available threads are used. I don't understand when you say that using two threads in a 2-core HT micro would be using 70% of the processor. I thought it used 100% physical and 50% logical, and that the remaining 50% was an aid to take advantage of segmentation.

          I did a quick test and I see that when running two processes, they are distributed among all available threads at approximately 50%. That is, all logical cores are being used at 50%. I thought they would only use two logical cores (presumably corresponding to two physical cores) at 100% and the other two would be kept at 0%.

          The truth is that I don't understand this behavior very well. Could it be that 50% of a logical core (the one shown in Task Manager) is half a physical core and the other half, half an HT core? It seems to me a bit strange management, but what if not?

          Certainly in Linux the issue is quite different.

          Toda la actualidad en la portada de Hardlimit
          Mis cacharros

          hlbm signature

          Bm4nB 1 Respuesta Última respuesta Responder Citar 0
          • Bm4nB Desconectado
            Bm4n @cobito
            Última edición por Bm4n

            @cobito I don't know if they have changed or improved the HT behavior, but when it was introduced it worked as follows: there are parts of the pipeline that are inactive on a core when resolving a thread. So HT adds a second thread of work so that those inactive parts can be used processing operations from another thread. That way you have two threads of work processing on a single core that works more fully by not having those "gaps" anymore. If a processor with HT only works with the physical cores (with HT disabled) it will never give 100% of its potential.

            alt text

            One of the main reasons why about 65% of your CPU's execution resources remain idle is due to the fact that the CPU can only execute one thread of instructions at a time. Think of a thread as a collection of instructions related to a single program, for example, running the spell checker in Word would send a thread of instructions to the CPU to start checking your document for spelling errors. It turns out that the instructions within a particular thread mostly use the same execution units over and over, leaving the remaining units idle. The idea behind Hyper-Threading is to send multiple threads to the CPU in the hopes that the idle execution units will be used by different threads. Intel claims that with HT enabled the utilization of the Pentium 4's execution units can jump to around 50%, which is not a bad improvement for such a small modification to the core.
            https://www.anandtech.com/show/1031/4

            What you say makes some sense, it's possible that it's balancing the load between its capabilities in the way that seems most optimal to the system. If you want to do a test, just look at how long it takes to process that task with HT enabled, putting that task to run only on the physical cores (you can do this manually in the task manager), with HT disabled in BIOS... do tests and you'll realize if it's really more efficient to run 2 processes exclusively on the physical cores or it's better to run those 2 processes in 4 threads even if two are HT (I bet on the second scenario).

            PD. I put a picture and a link to an article by Anand that explains it better than I can, also how OSes affect this and that HT, contrary to subtracting performance, usually adds it.

            hlbm signature
            ↳ Mis componentes

            1 Respuesta Última respuesta Responder Citar 1
            • 1 / 1
            • First post
              Last post

            Foreros conectados [Conectados hoy]

            1 usuarios activos (1 miembros y 0 invitados).
            febesin, pAtO, HIAL-9000

            Estadísticas de Hardlimit

            Los hardlimitianos han creado un total de 543.5k posts en 62.9k hilos.
            Somos un total de 34.9k miembros registrados.
            roymendez ha sido nuestro último fichaje.
            El récord de usuarios en linea fue de 123 y se produjo el Thu Jan 15 2026.