Du befindest dich hier: FSI Informatik » Prüfungsfragen und Altklausuren » Prüfungen im Bachelor-Studium (1. - 5. Semester) » pfp » Aufgabe 1 (Übersicht)
Dies ist eine alte Version des Dokuments!
Aufgabe 1
- a) volatile, synchronized. (static ? Aber keine Sichtbarkeitsgarantie im 'parallelen' Sinne)
- b) p(n) ist der parallele Anteil. B_p ist der Speedup.
- c) Entzug von Betriebsmitteln. Globale Ordnung der Betriebsmittel.
- d) Filteroperationen. Abbildungsoperationen (z. B. map)
Aufgabe 4
Block 1
new CyclicBarrier(threads + 1);
Block 2
for (int i = 0; i < threads; i++) { int end = start + step; // exclusive upper bound if (i == threads - 1) { end = array.length; } Thread thread = new CountingThread(start, end); thread.start(); }
Block 3
for (int i = 0; i < count.length; i++) { globalCounts.addAndGet(i, count[i]); }
Block 4
// oben barrier.await(); // unten barrier.await();
Aufgabe 5
- a)
def flatten: List[(Char, Char)] => List[Char] = input => input.map(tuple => List(tuple._1, tuple._2)).flatten * b)
def countPar: List[Char] => List[(Char, Int)] = cs => cs.par.map(c => (c, cs.par.filter(_ == c).size)).toList * c)
def distinct: List[(Char, Int)] => List[(Char, Int)] = xs => xs.foldLeft(List[(Char, Int)]())((res, curEntry) => if (res.contains(curEntry)) res else curEntry :: res)
Aufgabe 6
- a)
def decodeTuple: ((Char, Int)) => Stream[Char] = { case (c, count) if count > 0 => c #:: decodeTuple((c, count - 1)) case (c, count) => Stream.Empty }
- b)
def decode: Stream[(Char, Int)] => Stream[Char] = { case Stream.Empty => Stream.Empty case ts => { decodeTuple(ts.head) #::: decode(ts.tail) } }