Posts

Week 32 - CST334 Final Week

 CST 334 - Week 8 This is our eighth and final week in CST334, also known as Operating Systems. In this class we learned about virtualization, concurrency, and persistence. Virtualization The OS gives each process the illusion of having the CPU to itself, when in reality it is sharing it with the OS and other processes. The OS does this through a variety of ways: Processes are executed directly on the CPU. The CPU uses interrupts and voluntary yields to regularly switch between different processes. The OS saves the current 'context' of each process when it is paused, and loads it when the process is ran again. Many scheduling policies, such as FIFO, Round Robin, or Multi-level Feedback, exist to give different processes a fair amount of CPU time. The OS also gives each process the illusion of having all memory to itself, when it is likewise sharing memory with other processes. Each process is presented virtual address, which the CPU translates to a physical address. The CPU use...

Week 31

Image
CST334 Week 7 This week was our seventh week in CST-334, also known as Operating Systems Operating Systems: Three Easy Pieces Chapter 36: I/O Devices Chapter 36 discusses the basics of I/O devices. Key Takeaways: Interrupts are used to tell the CPU when a I/O request is complete. A Direct Memory Access (DMA) engine is a specialized device for handling I/O requests. Explicit I/O instructions and memory-mapped I/O are two ways to interact with I/O devices. Device Drivers is a piece of software that knows how a device works, and abstracts that device to the system. A basic protocol for an I/O device might be: Wait for drive to be ready. Write parameters to command registers. Start the I/O. Data transfer (for writes). Handle interrupts. Error handling.  Chapter 37: Hard Disk Drives Chapter 37 discusses hard disk drives. Key Takeaways: Data in HDDs is partitioned in blocks.  A platter is a circular, hard surface within a HDD that stores data. Each platter has two sides, and HDDs ma...

Week 30

 CST-334 Week 6 This is our sixth week in CST-334, also known as Operating Systems. Operating Systems: Three Easy Pieces This week we read chapters 30-32 of our textbook. Chapter 30: Condition Variables Chapter 30 discusses condition variables. Key Takeaways: Threads can use condition variables to check if a condition is true before executing. Condition variables are queues that threads can wait on. Waiting threads can then be woken when the condition variable changes. The function  pthread_cond_wait(cond, mutex)  adds a thread to the queue, releases the lock, and puts it to sleep. Cond is the condition variable. Mutex is the lock. The function  pthread_cond_signal(cond)  wakes the next thread in the queue and gives it the lock. Cond is the condition variable. You should use while loops instead of if statements when checking a condition variable.  Chapter 31: Semaphores Chapter 31 discusses semaphores. Key Takeaways: A semaphore is an object that contains a...

Week 29

 CST-334 Week 5 This is our fifth week in CST-334, also known as Operating Systems. Operating Systems: Three Easy Pieces This week we read chapters 26-29 in our textbook. Chapter 26: Concurrency and Threads This chapter discusses concurrency and the basics of threads. Key Takeaways: A multi-threaded program has multiple points of execution, called threads. Threads share the same code and heap, but have different stacks. Threads are used to utilize parallelism or keep a program running during I/O requests. Multi-threaded programs can be indeterminate. Race conditions, also called a data races, are outputs or variables that change based on the timing of the code's execution. Critical sections are pieces of code that access shared variables. Atomic instructions are executed completely or not at all.  Chapter 27: Thread API This chapter discusses functions for creating and using threads. Key Takeaways: The function pthread_create(thread, attr, start_routine, arg) is used to creat...

Week 28

 CST-334 Week 4 This week is our fourth week in CST-334, also known as Operating Systems. Operating Systems: Three Easy Pieces This week we read chapters 18-22 of our textbook. Chapter 18: Introduction to Paging Chapter 18 discusses the basic concepts behind paging. Key Takeaways: Memory is split into many sections of the same size. These sections are called pages or page frames. The OS keeps a list of free pages, known as a free list.  The OS keeps a page table for each process, which stores address translations for each of the virtual and physical pages associated with the process. The OS virtual memory addresses into a VPN and an offset. The VPN is used to find the correct page, and the offset is used to find the correct location within a page. An entry on a page table may have extra metadata bits, such as protection bits, valid bits, or dirty bits.  Chapter 19: Translation Lookaside Buffers Chapter 19 discusses Transaction Lookaside Buffers (TLB), and how they can be ...

Week 27

CST 334 This is our third week in CST-334, also known as Operating Systems. Operating Systems: Three Easy Pieces This week we read chapters 13-17 in our text book. Chapter 13: Address Spaces Chapter 13 discusses the virtualization of memory, or address spaces. Key Takeaways: Each process has an address space, an abstraction of where its memory is located in physical memory. The goals of virtual memory are transparency, efficiency, and protection. Chapter 14: Memory API Chapter 14 discusses the malloc and free functions in the C language. Key Takeaways: The malloc function attempts to allocate memory on the heap. It returns a pointer to the allocated memory on a success, or NULL on a failure. The free function takes a pointer returned by malloc, and frees the associated memory. Several errors are possible with manual memory management, such as forgetting to allocate memory, not allocating enough memory, forgetting to initialize allocated memory, forgetting to free memory, and freeing me...

Week 26

CST-334 Week 2 This week was our second week in CST-334, also known as Operating Systems. Operating Systems: Three Easy Pieces This week we read chapters 4-8 of our course textbook. Chapter 4: Processes This chapter discusses processes, which are running programs, and how the OS virtualizes the CPU to run multiple processes. Key Takeaways: The OS runs multiple processes by stopping and starting them during context switches. All OSs have APIs that processes use to interact with resources and the OS. To create a process executable code of a program must be loaded from storage onto memory. Processes can be running, ready, or blocked. The OS tracks data for each process.  Chapter 5: Process API This chapter discusses certain important aspects in Process APIs. Key Takeaways: The fork() system call creates a new process. The new process is identical to its parent process when it made the system call. The wait() system call allows a process to wait for another process, or its child proces...