Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


SSL multithreading.scala   Sprache: Scala

 
/*  Title:      Pure/Concurrent/multithreading.scala
    Author:     Makarius

Multithreading in Isabelle/Scala.
*/


package isabelle


object Multithreading {
  /* physical processors */

  // slightly different from Poly/ML (more accurate)
  def num_processors(ssh: SSH.System = SSH.Local): Int =
    if (ssh.isabelle_platform.is_macos) {
      val result = ssh.execute("sysctl -n hw.physicalcpu").check
      Library.trim_line(result.out) match {
        case Value.Int(n) => n max 1
        case _ => 1
      }
    }
    else {
      val Physical = """^\s*physical id\s*:\s*(\d+)\s*$""".r
      val Cores = """^\s*cpu cores\s*:\s*(\d+)\s*$""".r

      val physical_cores: Int = {
        var physical: Option[Int] = None
        var cores = Map.empty[Int, Int]

        val result = ssh.execute("cat /proc/cpuinfo").check
        for (line <- Library.trim_split_lines(result.out)) {
          line match {
            case Physical(Value.Int(i)) => physical = Some(i)
            case Cores(Value.Int(i))
              if physical.isDefined && !cores.isDefinedAt(physical.get) =>
              cores = cores + (physical.get -> i)
            case _ =>
          }
        }
        cores.valuesIterator.sum
      }

      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()
    }


  /* max_threads */

  def max_threads(
    value: Int = Value.Int.unapply(System.getProperty("isabelle.threads""0")) getOrElse 0,
    default: => Int = num_processors()
  ): Int = {
    if (value > 0) value else (default max 1) min 8
  }
}

94%


¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge