###### tags: `Operativsystemmer & C` # Operativsystemmer & C - NOTER til forelæsning ## Forselæsning 1 ### 3 fundamental abstractions for computer systems - Memory abstraction .. read // write ei. RAM - Interpreter abstraction ..execution of instruction - Communication abstraction ..send abd recieve ## Mutex Synchronization primitive - MUTEX - Is a shared variable that guarantees that a data structure can only be accessed atomically o Taking and sharing a mutex, before access a variable – then you can read and write o Is the mutex free? Test and set (if true) is atomic o Is like a lock, when having the mutex, no one else can access it o If multiple cores  Find a way so the lock itself will be copied across  Inefficient across cores, kill performance  On one core very efficient  You can use a single mutex to lock multiple shared variables  o If it fails then it have to ask again… What is a mutex - Test AND set need to be done automatically (using a single operation) - Otherwise multiple threads can ask if available, get a yes and then both reserve simultaneously NOTE: don’t compare _and_swap across cores ## EXAM notes when talking through it... **Phrase the question as you know it – then answer it as specific as you can – show off!** Question 1 (25%): Data Lab A. Describe your implementation of IsPower2(x) B. How would you change your implementation of copyLSB(x) to set all bits of result to the most significant bit of x? - shift only once - 31 to the right. Under the assumption of using arithmetic bit shifting Question 2 (25%); Perf Lab A. Do the benefits of loop unrolling keep on increasing as the number of unrolled operations increases? Explain your answer and give examples based on your assignment. B. Give an example illustrating how SIMD processing increases performance. Explain how SIMD impacts performance. Question 3 (25%): Malloc Lab A. Describe the design of your solution to malloc lab. B. Explain in details your implementation of the free function. Question 4 (25%): Topics from the class A. Describe what happens when executing the following instruction movl (%ebx), %eax. B. Are footers necessary when implementing segregated free list for dynamic memory management? Explain your answer. C. What is an inode? D. What is a stack frame? E. What is a mutex?