• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 15 páginas
Examen

Purdue CS 252 Final Study Guide Exam With Complete Solutions

Document preview thumbnail
Vista previa 2 fuera de 15 páginas

Purdue CS 252 Final Study Guide Exam With Complete Solutions...

Vista previa del contenido

Purdue CS 252 Final Study Guide Exam
With Complete Solutions



thread - ANSWER Path of execution. By default, each program has a main
thread that executes main().

Every thread has its own...
Stack
PC - Program Counter
Set of registers
State

What are some of the application of threads? - ANSWER Threads help
divide up the work, can be used in applications like servers. This leads to a
faster overall completion time if they are doing independent tasks.

What are the advantages of threads? (versus processes) - ANSWER *Fast
thread creation* - creating a new path of execution is easier.
*Fast context switch* - context switch across threads is faster than across
processes.
*Faster communication* - fast & easy to talk between threads. (processes
require pipes, etc).

What are the disadvantages of threads? (versus processes) - ANSWER
*Threads are less robust* - if one thread crashes, the entire application will
crash. If one process crashes, all other processes remain running.
*More sync problems* - Since threads modify the same global variables at
the same time, they may corrupt data structures. Synchronization is
required.

, What is an atomic section of code? - ANSWER A portion of code that only
one thread should execute at a time, while the other threads wait.
Sometimes called a "critical section".

What are mutex locks? - ANSWER Mutex locks are software mechanisms
that enforce atomicity. They enforce mutal exclusion of two or more
sections of code if the same lock is used.

What are the two mutex lock implementations? - ANSWER *Disable
interrupts*: Used only in Kernel mode, so that context switches cannot
happen. May lose interrupts and can be slow.
*Spin locks*: Can be implemented in user space, rely on the test_and_set
assembly instruction (since it is guaranteed atomic).

What are spin locks? - ANSWER A type of lock that rely on the
test_and_set assembly instruction, which is guaranteed to be atomic.
Mutex locks are implemented on top of spin locks.

Spin locks makes the thread "spin", or keep checking a while loop, rather
than putting the thread to sleep.

What are the advantages and disadvantages of spin locks? - ANSWER
*Advantages*
- Does not have any system overhead since the threads are not being put
to sleep
- Easy to implement, can be used in small sections that take a short
amount of time.

*Disadvantages*
- Spin locks do not enforce fairness, whichever thread unlocks it can use it.
There is no FIFO queue.
- Clock cycles are wasted since the threads do not do anything besides
"spin".

What is the difference between calling yield() in a spin lock versus nothing?
- ANSWER If we decide to call pthread_yield(), we are checking the
condition once, then devoting the rest of our clock cycles to other
processes. There is no need for the thread to constantly check the
condition of the lock, it can do so on the next quantum. Thus, if we use the
yield command, the thread that has the lock can complete more work,

Información del documento

Subido en
24 de agosto de 2026
Número de páginas
15
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$17.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Zayla
3.2
(20)
Vendido
162
Seguidores
13
Artículos
18418
Última venta
21 horas hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes