Operating Systems at Helmut-Schmidt-Universität/ Universität Der Bundeswehr | Flashcards & Summaries

Lernmaterialien für Operating Systems an der Helmut-Schmidt-Universität/ Universität der Bundeswehr

Greife auf kostenlose Karteikarten, Zusammenfassungen, Übungsaufgaben und Altklausuren für deinen Operating Systems Kurs an der Helmut-Schmidt-Universität/ Universität der Bundeswehr zu.

TESTE DEIN WISSEN

What are advantages of using threads in an application?

Lösung anzeigen
TESTE DEIN WISSEN
  • Blocking access to an I/O device blocks only one thread and not the entire process
  • Shorter response times for user entries
  • Several CPUs/Hyperthreading allows parallel execution
  • Concurrent programming is simplified: Multiple functions can be started and executed simultaneously 
Lösung ausblenden
TESTE DEIN WISSEN

What are Threads?

Lösung anzeigen
TESTE DEIN WISSEN

Lightweight Processes: Multiple threads may belong to one process which can be executed quasi-parallel (time-sharing) or truly parallel (multi-core) and are scheduled by the process or the OS

Shared Memory: They have shared virtual memory (virtual global variables) and their own stacks. However there is conflict potential as with IPC/SHM

Lösung ausblenden
TESTE DEIN WISSEN

Explain the Matrix Algorithm to detect Deadlocks

Lösung anzeigen
TESTE DEIN WISSEN
  1. Let all processes P be unmarked
  2. Find a process where r <= a applies 
  3. If such a process exists add C to a and mark the process P
  4. If there is no such P stop, otherwise go to 2

If the algorithm stops and there a still unmarked processes left over it means that those are in a deadlock

Lösung ausblenden
TESTE DEIN WISSEN

Give two synchronization types

Lösung anzeigen
TESTE DEIN WISSEN

Lock Synchronization:

  •  processes/threads must not occur simultaneously 
  • the order of execution is irrelevant

Sequence Synchronization:

  • Activities must be executed in a specific order
Lösung ausblenden
TESTE DEIN WISSEN

What is a Semaphore?

Lösung anzeigen
TESTE DEIN WISSEN

Semaphores are integer variables Si that belong to the OS and provide the following assurances:

  • Si >= 0
  • Decrement function p(Si,d)
  • Increment function v(Si,e)
  • Increments run atomically 
  • Decrements run atomically with the following exception:

Decrements are blocked if Si-d<0, as long Si is not increased sufficiently

If multiple calls are called => First Come First Serve

Lösung ausblenden
TESTE DEIN WISSEN

What are the conditions for a deadlock? Which of them are a necessary condition?

Lösung anzeigen
TESTE DEIN WISSEN
  1. Mutual Exclusion
  2. Hold and Wait  (A process that holds already a resource can request an additional one)
  3. No preemption (A resource cannot be removed from a process)
  4. Circular Wait (deadlock occurs -> cyclic chain where each process is waiting for a resource held by the next process)

1-3 are necessary prerequisites for the fourth condition. If the fourth condition does not arise, no deadlock occurs

Lösung ausblenden
TESTE DEIN WISSEN

Give three software ideas to ensure mutual exclusion!

Lösung anzeigen
TESTE DEIN WISSEN

1. Use inUse Flag before entering critical section.

Problem: If the while statement is read by both before one flag is set, both enter the critical section

2. Use a turn flag after critical section. Thread 0 has to start.

Problem: Threads must alternate to continue. Violates Requirements 2,3 and 4

3. Use interested[I] flag and set it before entering the while loop.

Problem: If both flags are set before entering the loop, no thread can enter the critical section -> Deadlock

Lösung ausblenden
TESTE DEIN WISSEN

Scheduling in process vs Scheduling in OS

Lösung anzeigen
TESTE DEIN WISSEN

Scheduling process                                             Scheduling OS

+Support by OS unnecessaryTruly parallel processing is possible
+no switching between user/operating system mode+If a thread is blocked, a new one can be activated
+ indivdual scheduling-Switching processes takes a lot of time
switching of mode
-A blocked thread blocks the entire processcreation/change/termination
requires system call
-Threads must work cooperatively
Lösung ausblenden
TESTE DEIN WISSEN

What is a Race condition in terms of synchronization?

Lösung anzeigen
TESTE DEIN WISSEN

If two threads/processes shall be executed simultaneously you can't tell which thread the compiler will execute first. The dependency on execution order is called race condition.

Lösung ausblenden
TESTE DEIN WISSEN

What is a better solution for busy waiting?

Lösung anzeigen
TESTE DEIN WISSEN

Process goes to sleep if critical section is in use. If another thread exits the critical region, it sends a wake up call. Then the state is again running.

Lösung ausblenden
TESTE DEIN WISSEN

Distinguish between preempt-able and non-preempt-able resources

Lösung anzeigen
TESTE DEIN WISSEN

A preempt-able resource can be withdrawn from a process like a processor or memory. This prevents the possibility of a deadlock. 

A non-preempt-able resource cannot be withdrawn from the process as the withdrawal would usually end in the termination of a process (Printer, CD burner). This can lead to a deadlock 

Lösung ausblenden
TESTE DEIN WISSEN

How can deadlocks be handled - Avoidance of a deadlock situation

Lösung anzeigen
TESTE DEIN WISSEN

Banker's algorithm:

The operating system checks if there is still a safe state even if the access is granted. This implies that you need to know the maximum requirement of the processes, this is often not known.

Lösung ausblenden
  • 9445 Karteikarten
  • 227 Studierende
  • 61 Lernmaterialien

Beispielhafte Karteikarten für deinen Operating Systems Kurs an der Helmut-Schmidt-Universität/ Universität der Bundeswehr - von Kommilitonen auf StudySmarter erstellt!

Q:

What are advantages of using threads in an application?

A:
  • Blocking access to an I/O device blocks only one thread and not the entire process
  • Shorter response times for user entries
  • Several CPUs/Hyperthreading allows parallel execution
  • Concurrent programming is simplified: Multiple functions can be started and executed simultaneously 
Q:

What are Threads?

A:

Lightweight Processes: Multiple threads may belong to one process which can be executed quasi-parallel (time-sharing) or truly parallel (multi-core) and are scheduled by the process or the OS

Shared Memory: They have shared virtual memory (virtual global variables) and their own stacks. However there is conflict potential as with IPC/SHM

Q:

Explain the Matrix Algorithm to detect Deadlocks

A:
  1. Let all processes P be unmarked
  2. Find a process where r <= a applies 
  3. If such a process exists add C to a and mark the process P
  4. If there is no such P stop, otherwise go to 2

If the algorithm stops and there a still unmarked processes left over it means that those are in a deadlock

Q:

Give two synchronization types

A:

Lock Synchronization:

  •  processes/threads must not occur simultaneously 
  • the order of execution is irrelevant

Sequence Synchronization:

  • Activities must be executed in a specific order
Q:

What is a Semaphore?

A:

Semaphores are integer variables Si that belong to the OS and provide the following assurances:

  • Si >= 0
  • Decrement function p(Si,d)
  • Increment function v(Si,e)
  • Increments run atomically 
  • Decrements run atomically with the following exception:

Decrements are blocked if Si-d<0, as long Si is not increased sufficiently

If multiple calls are called => First Come First Serve

Mehr Karteikarten anzeigen
Q:

What are the conditions for a deadlock? Which of them are a necessary condition?

A:
  1. Mutual Exclusion
  2. Hold and Wait  (A process that holds already a resource can request an additional one)
  3. No preemption (A resource cannot be removed from a process)
  4. Circular Wait (deadlock occurs -> cyclic chain where each process is waiting for a resource held by the next process)

1-3 are necessary prerequisites for the fourth condition. If the fourth condition does not arise, no deadlock occurs

Q:

Give three software ideas to ensure mutual exclusion!

A:

1. Use inUse Flag before entering critical section.

Problem: If the while statement is read by both before one flag is set, both enter the critical section

2. Use a turn flag after critical section. Thread 0 has to start.

Problem: Threads must alternate to continue. Violates Requirements 2,3 and 4

3. Use interested[I] flag and set it before entering the while loop.

Problem: If both flags are set before entering the loop, no thread can enter the critical section -> Deadlock

Q:

Scheduling in process vs Scheduling in OS

A:

Scheduling process                                             Scheduling OS

+Support by OS unnecessaryTruly parallel processing is possible
+no switching between user/operating system mode+If a thread is blocked, a new one can be activated
+ indivdual scheduling-Switching processes takes a lot of time
switching of mode
-A blocked thread blocks the entire processcreation/change/termination
requires system call
-Threads must work cooperatively
Q:

What is a Race condition in terms of synchronization?

A:

If two threads/processes shall be executed simultaneously you can't tell which thread the compiler will execute first. The dependency on execution order is called race condition.

Q:

What is a better solution for busy waiting?

A:

Process goes to sleep if critical section is in use. If another thread exits the critical region, it sends a wake up call. Then the state is again running.

Q:

Distinguish between preempt-able and non-preempt-able resources

A:

A preempt-able resource can be withdrawn from a process like a processor or memory. This prevents the possibility of a deadlock. 

A non-preempt-able resource cannot be withdrawn from the process as the withdrawal would usually end in the termination of a process (Printer, CD burner). This can lead to a deadlock 

Q:

How can deadlocks be handled - Avoidance of a deadlock situation

A:

Banker's algorithm:

The operating system checks if there is still a safe state even if the access is granted. This implies that you need to know the maximum requirement of the processes, this is often not known.

Operating Systems

Erstelle und finde Lernmaterialien auf StudySmarter.

Greife kostenlos auf tausende geteilte Karteikarten, Zusammenfassungen, Altklausuren und mehr zu.

Jetzt loslegen

Das sind die beliebtesten Operating Systems Kurse im gesamten StudySmarter Universum

Operating System

National University of Science and Technology

Zum Kurs
operation system chapter 1

Al-Imam Mohamed Ibn Saud Islamic University

Zum Kurs
Operating systems

University of Cape Town

Zum Kurs
Sistemas Operativos

Universidad Politécnica de Madrid

Zum Kurs

Die all-in-one Lernapp für Studierende

Greife auf Millionen geteilter Lernmaterialien der StudySmarter Community zu
Kostenlos anmelden Operating Systems
Erstelle Karteikarten und Zusammenfassungen mit den StudySmarter Tools
Kostenlos loslegen Operating Systems