Posts

CST-334 Week 6

 This week I learned more about conditional variables, semaphores, and how to write code using semaphores. One of the solutions we came up with was the polling solution. In this case, we want to occasionally read from the shared resource. An example of this could look something like: static int some_value = 0; void* read(void* thread) {     while (1) {          sleep(1);          some_value = get_value();     } } void* api(void* thread){ while (1) {      if (some_vaue != old_value) {          old_value = some_value;     } } } In this example, the shared resource (some_value) is being constantly read inside our loop. This ensures that we can run some condition whenever the value store inside our variable changes. However, this introduces some problems. This solution is inefficient as it is constantly running to check to the value stored inside some_value, caus...

CST-334 Week 5

 This week, I learned the benefits of concurrency, the C pthreads API, and how locks are used to protect programs from race conditions. Concurrency is beneficial as it is a useful programming abstracting, increases responsiveness, and it can leverage multicore machines and GPUs. On the other hand, concurrency can introduce bugs related to concurrency, and it can cause programs to be non-deterministic. A program is not deterministic when the output of the program is not expected and changed each time it is ran. This is commonly caused by race conditions. A race condition arises when multiple threads of execution enter the critical section (a shared resource) at roughly the same time. The threads will attempt to update the shared data structure and as the schedular will be making the decision on which thread will be run, the output if the program will become undesirable. Programs can avoid these problems by having threads use some kind of mutual exclusion primitive, which will guaran...

CST-334 Week 4

 This week I learned more about managing free space in memory, more translation techniques using paging, and the different policies that determine when a page should be swapped out into disk. In memory, external fragmentation will cause free space to be chopped up into little pieces of different sizes. This may cause some requests to fail as there may be no space left to fit the request. To solve this problem, a free list data structure can be used to manage free space in the heap. A free list looks similar to a linked list data structure. Each node contains an address of where space is free and the length of that free space. When requesting in memory that may be smaller than what is available in a free chunk, the allocator will split a free chunk into two so it can satisfy the request. In the opposite case, when a chunk of memory is free, the allocator will coalesce free space. There are different strategies that are used for managing free space, best fit, worst-fit, and first-fit...

CST-334 Week 3

 This week I learned about address spaces, techniques for translating virtual addresses to physical memory, and some C apis for allocating and deallocating memory. An address space is a running program's view of its memory in the system. This program's address space will not be the same as its exact space in physical memory due to virtualization. The purpose of virtualizing the program's memory is that it allows for transparency, efficiency, and protection from other processes or the OS from processes. The program will think its address space starts at 0 (and so will the CPU), but the MMU will translate the program's address space into physical memory by techniques such as, base-and-bounds, segmentation, and paging.  Base-and-bounds translation is a technique for translating virtual addresses into physical ones by having the CPU assign a process a base register and a bounds register. The base register will be its actual location in memory, and the bounds register will b...

CST-334 Week 2

The topics we covered this week are processes, how the OS manages them, and the different schedulers that decide which processes should run at a given time. A process is essentially a running program that executes on the CPU. Processes run in user mode and do not have access to privileged instructions. When a process needs to perform a restricted operation, it makes a system call that triggers a trap, allowing the OS to take control in kernel mode and safely execute the requested task before returning to user mode. The different scheduling algorithms that we studied this week include FIFO, a scheduling program that runs the first process in a queue, SJF, a schedular which run the process with the shortest execution time, and Round Robin, a scheduler that switches between processes based on a time splice. I think one of the more difficult topics for me this week was how to schedule process using the Round Robin scheduler. I was able to understand this conceptually but had some difficult...

CST-334 Week 1

The topics I learned this week are the basic concepts of an operating system, converting from binary to hexadecimal, and using bash scripts to run C programs. One of the uses of an operating system is to allow programs to share memory and enables programs to interact with devices that are in charge of making sure the system operates correctly and efficiently. An important concept in operating systems that I learned this week is virtualization. Virtualization allows the OS to take physical resources and transform them into a more general, powerful, and easy-to-use virtual form of itself (a virtual machine). I was able to practice these concepts through lab 1 and the first homework assignments. In these assignments, we learned to use docker to host a virtual OS so we could build C programs. Through these assignments, I was able to strengthen my understanding of memory allocation. I had some experience with using pointers in C++, but I was somewhat confused on how malloc() worked and why ...

CST-363 Week 8

Briefly summarize what you consider to be the three (3) most important things you learned in this course. Learning MySQL to query/update data from a database. Learning about alternative databases, such as the NoSQL database, and using MongoDB/Java to create a web application. Learning to normalize a database to reduce redundancy in a database by following Third Normal Form or BCNF.