COS3721 Practise notes PDF

Title COS3721 Practise notes
Course Operating Systems And Architecture
Institution University of South Africa
Pages 16
File Size 325.6 KB
File Type PDF
Total Downloads 649
Total Views 704

Summary

Download COS3721 Practise notes PDF


Description

Interrupts are signals generated by hardware within the system. They communicate with the CPU to stop its current activities and execute the appropriate part of the operating system Traps are software-generated traps. A trap is to indicate that some error or condition occurred for which assistance from the operating system is needed. Traps can be generated intentionally by a user program, because they give the user better control over the computer. Single-processor systems - one main CPU with one cache, executing only one process at a time, the cache is readily up to date. Multiprocessor systems - each CPU has its own cache and a shared cache and the main memory. Without cache coherence, each CPU might store a local copy of some data and changes on that particular data will not persist between CPUs. Thus, accessed data may be out of date or inconsistent between processors Distributed systems- several copies of the same file can be kept on different computers that are distributed in space. The changes to one file are not visible to the rest of the system, unless each copy is constantly kept up-to-date. Advantages and disadvantages of using the same system call interface for manipulating both files and devices? Advantages: - Easy to add new devices and implement them on system since devices are recognized as a file in the file system and kernel works with devices through file interface Disadvantages: - Difficult to implement all functionality of certain devices within the file system, sand that causes a loss of functionality and limits performance. Message-passing model: Strength-Useful for exchanging smaller amounts of data Weakness- communication is slow because of the time involved in connection setup Shared-memory model: Strength: communication process is fast. Weaknesses: different processes can access to same memory locations simultaneously cause loss of data or incorrect information. We need to ensure that processes using this communication style need to be executed properly to avoid this problem. iOS and Android Similarities • Both are built on existing kernels •

Provide frameworks for developers and,



Have architecture that uses software stacks.

• •

Both run on tablets computers and smartphones Both separate user files from system files, and encrypt user file not the system file  data can be erased without harming the system  system can be upgraded without harming user data Differences • iOS is closed source whereas Android is open source • iOS's applications are developed in Objective-C. Android on the other hand in Java, • iOS is coded natively. android uses a virtual machine. Processes fork()- system call creates a new process. Because the child is a copy of the parent, any changes the child makes will occur in its copy of the data.

pid = fork() – gets the child process id If priority is the same, interrupting process will go in, and execute for as long as the agreed time unit. Turnaround time = completion time - arrival time Waiting time = Turnaround time – burst time Threads and Concurrency Using Amdahl’s Law,

Synchronization tools  The lock is to be held for a short duration. Use a spinlock. There will be much less overheard if process waits 3-4 cycles, then performing two context switches (first for removing a blocked thread and placing a new thread to run, second for reversing this process). Linux Kernel tends to use spinlock for processes that should busy wait for a short duration of time.  The lock is to be held for a long duration. Use a mutex. In this case the reasons given for spinlock in previous answer do not apply when the lock is to be held for a long duration  A thread may be put to sleep while holding the lock. Use a mutex. If the code puts thread/process in a critical section. This is bad code. However, it is possible that thread/process which is in critical section was put to sleep. This probability is greater the longer that/process is running. In this case you should use a mutex. The thread which can’t access the critical section will waste less cycles this way than if it was busy waiting. The Linux kernel has a policy that a process cannot hold a spinlock while attempting to acquire a semaphore. Explain why this policy is in place. Because acquiring a semaphore may put the process to sleep, while it is waiting for the semaphore to become available. Software transactional memory (STM), implements Transactional memory exclusively in software—no special hardware is needed. STM works by inserting instrumentation code inside transaction blocks. Hardware transactional memory (HTM), uses hardware cache hierarchies and cache coherency protocols to manage and resolve conflicts involving shared data residing in separate processors’ caches. HTM requires no software support. 3 types of traditional hypervisors.  Type 0—implemented by Firmware, low overhead but generally fewer features. Other VMMs can run as guests.  Type 1—special purpose software or general-purpose operating systems that provide a means to run guests. Takes advantage of available hardware assistance, most feature rich.  Type 2—application providing guest execution unbeknownst to the operating system. More overhead and fewer features than type 1. what method can a VMM use to implement virtualization? CPUs don’t neatly isolate privileged and non-privileged directions like the x86, which has maintained backwards compatibility and accordingly similar issues with virtualization. 

In x86’s client mode just a few Flags are supplanted from the stack while the rest are disregarded and along these a trap isn’t created and trap-and emulate can’t be utilized. Rather, binary translation can be utilised.

Deadlocks when applying the four-deadlock condition, a dead lock can still occur. However, the multiple reader–writer should be as follows: 1. Mutual exclusion is maintained, and they cannot be shared since there since there’s a writer. 2. Hold-and-wait is possible. The thread can hold one reader/writer lock while waiting for another. 3. No pre-emption is upheld. 4. Finally, a circular wait between threads is possible. Safe and unsafe states In order to determine whether or not each state is unsafe, one has to follow the below steps. Step 1: find the need of each process. 𝑛𝑛𝑛𝑛 = 𝑛 𝑛𝑛 − 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 Step 2: for each process, evaluate if the available is greater or equal to the need Step 2a: if the need is greater, skip process Step 2b: if available is greater or equal, subtract the need from the available and update the available to 𝑛 𝑛𝑛 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 =𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 + 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 Step 3: Capture order of subtraction Step 4: Repeat the above for each skipped process, until all processes have been successfully executed. Contiguous memory allocation - This might require relocation of the entire program since there is not enough space for the program to grow its allocated memory space Paging - This doesn’t require relocation of the program’s address space, since the incremental allocation of new pages is possible in this scheme. Paging solution: Given 1Kb page size we can express this as 2𝑛 (where n is the number of bits in offset part). Therefore, 1𝑛𝑛 = 1024 = 210. In this case 𝑛=10. To solve each of the above addresses, the following steps will be followed. Step 1: convert logical address from decimal to binary Step 2: Split binary address to 2 parts (page no, offset) where offset=n digits of the binary value. Step 3: Convert offset and page no from binary to decimal. e.g. 21205 1. Binary format: 101001011010101 2. Page no.: 10100, offset: 1011010101 3. Page no.: 20, Offset: 725 Consider a computer system with a 32-bit logical address and 8-KB page size. The system supports up to 1 GB of physical memory. How many entries are there in each of the following? a. A conventional, single-level page table 212...


Similar Free PDFs