Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

COP4600 Midterm Review Exam Questions and Answers with Complete Solutions | 100% pass, Exams of Computer Science

COP4600 Midterm Review Exam Questions and Answers with Complete Solutions | 100% pass

Typology: Exams

2024/2025

Available from 02/24/2025

catewilliams-smith
catewilliams-smith 🇺🇸

172 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP4600 Midterm Review Exam Questions
and Answers with Complete Solutions | 100%
pass
______ is a part of a process that has ______ - ✔✔Thread;
It's own execution history( can't have without a stack)
Program Counter
Stack
Every process has ______ threads and every thread ____ - ✔✔one or more threads;
belongs to exactly one process
Elements that are unique to a process but not a thread - ✔✔text(instructions)
data (constants/statics)
heap( dynamic allocations)
Reason to use multiple threads instead of process - ✔✔Can reduce overhead and facilitate sharing
**Threading: Classical Model; Explain Uniprogrammed, Multiprocess Model, and Threaded Model -
✔✔Uni: One process at at time, wait for a process to finish;
Multiprocess:Process switch in and out.
Threaded switch between threads within a process. ( this reduces context switch times)
Why do we use threads - ✔✔-break up complicated tasks into simple ones
-improve efficiency
pf3
pf4
pf5
pf8

Partial preview of the text

Download COP4600 Midterm Review Exam Questions and Answers with Complete Solutions | 100% pass and more Exams Computer Science in PDF only on Docsity!

COP4600 Midterm Review Exam Questions

and Answers with Complete Solutions | 100%

pass

______ is a part of a process that has ______ - ✔✔Thread; It's own execution history( can't have without a stack) Program Counter Stack Every process has ______ threads and every thread ____ - ✔✔one or more threads; belongs to exactly one process Elements that are unique to a process but not a thread - ✔✔text(instructions) data (constants/statics) heap( dynamic allocations) Reason to use multiple threads instead of process - ✔✔Can reduce overhead and facilitate sharing **Threading: Classical Model; Explain Uniprogrammed, Multiprocess Model, and Threaded Model - ✔✔Uni: One process at at time, wait for a process to finish; Multiprocess:Process switch in and out. Threaded switch between threads within a process. ( this reduces context switch times) Why do we use threads - ✔✔-break up complicated tasks into simple ones

  • improve efficiency

compared to new processes, threads have - ✔✔-lower memory cost(shared segments)

  • information sharing ( through shared data)
  • reduced creation, destruction time (allocation, copying)
  • reduce context time ( to another thread in the same process only) What's in a thread? (Give Process Specific versus Thread Specific Components) - ✔✔Specific to A Thread: Program Counter Registers Stack State Specific to A Process: Address Space Global Variables Open file Child processes Pending alarms signals and handlers CPU accounting Describe the differences between kernel and user space threads - ✔✔User threads:
  • User Library
  • OS-Independent
  • Syscalls block all process threads
  • Process threads in 1 CPU
  • Procedure calls (quick/cheap)

What do process need to communicate to each other? And what two problems does this mean we have to address? - ✔✔Process have to: Transmit data Notify each other of events (user did something dumb) Update Status ( I'm alive, don't kill me) Two Problems: Synchronize process ( so they can communicate) Actually transfer the info IPC Shared Memory versus Message Passing - ✔✔Share Memory: Directly write to memory require shared space caching & consistency issues requires explicit synchronization Message Passing: library or OS support needed some assembly required handles synchronization issues avoid memory specific problems _____ accepts data parcels and deliver them between processes - ✔✔Message passing systems Two main message passing systems mentioned in slides - ✔✔Pipes: Named/Unnamed (Unnamed: Parent to child, Named: 2 diff processes Linux ) Set and Use Local Host Only

Networks : TCP/UDP Requires more setup Host to host support When do we get a race condition? - ✔✔When results depend on timing that is not synchronized What are critical regions/sections? - ✔✔Regions of codes that we must protect. What must we maintain to avoid race conditions? - ✔✔1. Concurrency: We can't make any assumptions about the speed or the # of CPUS

  1. Safety: No 2 process may simultaneously within their (related) CRs
  2. Liveness:No process running outside of the CR may block other processes inside it.
  3. Liveness: No process should have to wait forever to wait its critical region We must have some atomic operations or at least equivalency( **REVIEW IN DETAIL) - ✔✔Direct atomic instructions : Load-Store: Load +Increment+Store Locking atomic instructions: Test And Set Lock (TSL What are the two primary synchronization criteria? - ✔✔Safety: Data and state remain consistent ( if you don't do this you may end up with invalid state of application data or invalid application functional state) Liveness: All processes will eventually complete. If not you end up with deadlock or starvation Name the ways to approach process synchronization - ✔✔Busy waiting ( spin lock, can be software or hardware based) Messaging (Network & pipes, OS support required)

Mutex:

  • Operations are lock and unlock only
  • Once locked, only the locking thread can unlock a mutex
  • Intended specifically for single-process-at-a-time critical regions Semaphore
  • Operations are up (increment) and down (decrement)
  • Any thread with access to the semaphore can increment or decrement
  • Provides resource counting/tracking
  • A binary semaphore is similar to a mutex but can be unlocked by any thread. (BINARY can be 0 or 1) How do Semaphores work? ( Hint: Operations) - ✔✔Semaphores are tightly controlled- the only operations are creation, up, and down. creation: semaphores can be created with a starting count down: if count>0, decrement & continue otherwise, block, & add called to this semaphore's queues up: if queue is empty, increment count & continue otherwise, remove and unblock the first process in the queue for this semaphore Note: The up operation never blocks!! Busy Waiting: Strict Alternation - ✔✔Strict alternation trades turns between two lines of execution; can result in time wasted waiting when two processes have diff. time needs. Busy Waiting: Flagging Interest - ✔✔We try to avoid excessive waits from strict alternation by indicating interest, but this can fail because the flagging and locking are not atomic

Peterson Solution - ✔✔Busywaiting; combines flagging and alternation approaches Why do spin locks suck? - ✔✔spin locks( busy waiting ) inefficiently use the CPU while waiting for a resource; What is the Producer Consumer problem - ✔✔-also called the bounded buffer problem

  • occurs when 1 or more producers & 1 or more consumers act on the same finite data buffer
  • producers: place data in the buffer
  • consumer: remove data from the buffer