src/Pure/Concurrent/multithreading.scala
changeset 79759 5492439ffe89
parent 79758 68f2fe632b4c
--- a/src/Pure/Concurrent/multithreading.scala	Sun Mar 03 16:32:59 2024 +0100
+++ b/src/Pure/Concurrent/multithreading.scala	Sun Mar 03 17:47:50 2024 +0100
@@ -39,7 +39,17 @@
         }
         cores.valuesIterator.sum
       }
-      if (physical_cores > 1) physical_cores else 1
+
+      def logical_cores(): Int =
+        if (ssh.is_local) Runtime.getRuntime.availableProcessors()
+        else {
+          Library.trim_line(ssh.execute("nproc").check.out) match {
+            case Value.Nat(n) => n
+            case _ => 1
+          }
+        }
+
+      if (physical_cores > 0) physical_cores else logical_cores()
     }