Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

threading

Divyesh
Beginner
328 Views

I have intel i3 processor on my laptop. though it has 2 cores it can run 4 threads at a time. When I see task manager I see programs with 11 threads , 40 threads. How are these threads scheduled? is it hardware implemented or managed by the host OS?

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
328 Views

The operating system, when it has more software threads to run than hardware threads, will run a software thread until the earlier of: time quanta (few ms) or I/O that blocks. At that point it suspends the thread, then chooses a waiting software thread to run on that hardware thread.

A program can have more software threads than hardware threads (usually because they are waiting for something to do).

For compute bound applications it is usually counterproductive to use more software threads than hardware threads and optionally those that would otherwise be idle during run of application. Meaning should your system have two compute bound applications then better performance might be seen, say on your system 2C/4T, to have each app use 1C/2T. This would avoid adverse L1 and L2 cache interactions.

Jim Dempsey

0 Kudos
Bernard
Valued Contributor I
328 Views

You can also add to this explanation thread priorities which are used to prioritize execution and choose the higher priority thread to run before the lower priority thread.

0 Kudos
Reply