Nachos 2
-
Upload
eduardo-triana -
Category
Technology
-
view
849 -
download
0
description
Transcript of Nachos 2
![Page 1: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/1.jpg)
NACHOS 2Theoretical Presentation
Carlos Eduardo Triana SarmientoJonathan Alvarado Mata
Obed David Guevara Ibarra
![Page 2: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/2.jpg)
• User program and its difference with Kernel
An user program is a sequence of instructions for a specific machine, which it can directly execute byloading in memory.
To ensure safety, security and consistency of kernel data structures, certain memory locations and instructions are available to the kernel only
Kernel runs in supervisor mode (or kernel mode) and as a manager for all resources available, it works on behalf of the user. Kernel loads one or many of those user programs in memory, allocates and de-allocates memory, registers and frees up resources
![Page 3: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/3.jpg)
Sumarizing, Kernel is what runs in supervisor mode, and all other is user programs
Compilers, window managers, and utility programs packaged with a typical operating system are actually user programs though they are part of system software
Now we can say that all the Linux distributions are basically same. If we don’t alter the kernel code, they differ only in provided utility programs.
![Page 4: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/4.jpg)
After the system boots up, kernel does some management tasks, creates and initializes the data structures necessary. Unix based operating systems then create Process 0 which runs in kernel mode. Process 0 forks and creates User mode Process called init(). Every other user programs are created by calling fork() copying parent’s address space. Record of parent child relationships are kept inside several kernel datastructures.
When user process is let to run, the system is in user mode and kernel mode (or supervisor mode) is achieved only via traps or system calls.
![Page 5: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/5.jpg)
When you invoke nachos with the "-x" flag, the MIPS simulator begins executing the user program specified, instruction by instruction (the MIPS simulator is an interpreter that reads in binary instructions and simulates their effect). Whenever an event occurs that the OS needs to know about, the simulator makes a procedure call into the Nachos kernel.
![Page 6: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/6.jpg)
The basic idea of virtual memory its: main memory used as a cache for backing store
Virtual memory is a memory management technique developed for multitasking kernels
Virtual memory makes it possible for computers to more easily handle larger and more complex applications
All implementations of virtual memory divide a virtual address space into pages, blocks of contiguous virtual memory addresses.
Pages are usually at least 4 kilobytes in size.
Virtual Memory
![Page 7: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/7.jpg)
Page tables are used to translate the virtual addresses seen by the application into physical addresses by the hardware to process instructions
Each entry in the page table holds a flag indicating whether the corresponding page is in real memory or not. If it is in real memory, the page table entry will contain the real memory address at which the page is stored. If the page table entry for the page indicates that it is not currently in real memory, the hardware raises a page fault exception, invoking the paging supervisor component of the operating system.
![Page 8: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/8.jpg)
For example, if you load the operating system, an e-mail, a web browser and word processor into RAM simultaneously, is not enough space to hold it all. If there were no Virtual Memory, then once you filled up the available RAM your computer would have to say: "Sorry, you can not load any more applications, please close another application to load a new one". With virtual memory, what the computer can do is look at RAM areas that have not been used recently and copy them onto the hard disk. This frees up space in RAM to load the new application.
![Page 9: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/9.jpg)
Pseudo-code VM
Construction and initialization
![Page 10: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/10.jpg)
![Page 11: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/11.jpg)
PageFault Exception Handler• calculate vpn• if (pageTable(vpn).valid) go case1 else go case2
Case 1: page is in MainMemory• update TLB
Case 2: page is not in MainMemory• find a free page: int ppn = memMap.find()• update coremap: coreMap->updateEntry(ppn, vpn);• update pageTable: TranslationEntry* entry =
currentThread->space->getPageTable(vpn)entry->virtualpage = vpn; entry->physicalPage = ppn; entry->…..
• load a page into ppn mainMemory from swapfile; currentThread->space->readFromSwap(vpn);
• update TLB
![Page 12: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/12.jpg)
FileFile SystemsSystemsAll computer applications need to store and retrieve information, overcoming the limitations of real storage.
The solution is to store information on disks and other external media files in units called: Files• The files are a collection of named data.• The files must be persistent, meaning that should not be
affected by the creation or termination of a process.• Can be manipulated as a unit operations such as: open,
close,create, destroy, copy, rename, list.• The individual data elements within the file can be manipulated
by operations such as: read, write, update, insert, delete.
The "File System" is part of the storage management systemmainly responsible for the administration of the files in secondary storage.
![Page 13: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/13.jpg)
The file system organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it.
Without a filesystem programs would not be able to access data by file name or directory and would need to be able to directly access data regions on a storage device.
To achieve optimal performance, the underlying file system configuration must be balanced to match the application characteristics.
Disk access is much slower than memory access:• Times measured in milliseconds and nanoseconds
respectively.• It should reduce the number of disk accesses.
File system
![Page 14: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/14.jpg)
File system
The most common technique to reduce disk accesses is the block buffer cache or cache, is as follows:• Check all read requests to see if the requested block is in
thecache.• If so, the request is satisfied without a disk access.• If not, read to enter the cache and then copied to the
placewhere needed.• When loading a cache block in a fully occupied:• Some block must be removed and re-written to disk if it
has been modified after having brought the disc.• It presents a situation very similar to paging and
solved withsimilar algorithms.
![Page 15: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/15.jpg)
An important technique to increase the performance of a file system is to reduce the amount of disk arm movements (access mechanism)Another solution is to write the changed blocks (cache) to diskas soon as it has been written (the cache):• Requires more e / s than other types of caches.
![Page 16: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/16.jpg)
In the worst case should consider a total system failure and its impact on the consistency of the file system:If a critical block, a block of an inode is read from the cache and modified without re-writing to disk, a total system failure will leave the filesystem in an inconsistent state.
![Page 17: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/17.jpg)
Control block of a file
![Page 18: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/18.jpg)
Directories in UNIX systems are organized keeping certain hierarchy
![Page 19: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/19.jpg)
![Page 20: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/20.jpg)
Pseudo-code
![Page 21: Nachos 2](https://reader035.fdocuments.net/reader035/viewer/2022062307/555ddc4dd8b42a1e2c8b492d/html5/thumbnails/21.jpg)
Bibliography
http://en.wikipedia.org/wiki/Virtual_memory
http://www.geocities.ws/hellopopel/nachos2.pdf
http://www-scf.usc.edu/~csci402/assignment2/p2_doc_new3.html#top
http://www.howstuffworks.com/virtual-memory.htm
http://exa.unne.edu.ar/depar/areas/informatica/SistemasOperativos/SO4.htm