Nach os assignment_2_teorica


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Nach os assignment_2_teorica

  1. 1. Operating Systems
  2. 2. Virtual Memory
  3. 3. Virtual memoryThe virtual memory is the separation between logical andphysical memory.In order to avoid external fragmentation, we can divide theinformation into smaller pieces called page frames, whichcontain the data of that page.
  4. 4. When there is not enough space to run a process, we cancompact or relocate it. We can also swap to the disk aprocess that is not being used. Then, when it becomesavailable we can restore the process.When we are looking for a process that is located in disk,a page fault occur.
  5. 5. ProblemsFIFO The worst result (higher rate Belady Anomaly of page faults)Optimization the best result (lower rate of not implementable page faults)LRU too much information plus hardware. Las ultimas paginas introducidas recientemente, estan continuamente reemplazandose.MFU Las paginas mas populares se reemplazan
  6. 6. Pseudocode structarray //data or elements initialized if b = null b address new dataa = null //count elsecreate b set pointer next address a++if array not avaiblereturn true if b = nullelse return falsereturn false move data add pointer of d to data.if b = fullreturn falsenew spacemove data to spacepointer new element/data
  7. 7. TLBA translation lookaside buffer (TLB) is a cache memoryadministrated by the MMU. It contains slots of the page table, italso maps the relationship between virtual and physicaladresses.The page table keeps the track of where the virtual pages areloaded into the physical memory.
  8. 8. Pseudocode if tlb = page faul goto to page tableTLB update() read swapinitializing user prog move data to memoryinitializing swapfile if page table valid bit = trueif user prog = null write swapreturn falseelseswap = *user prog find next tlb if tlb dirty bits/data = trueinitializing page table page table dirty entry uppointer to address
  9. 9. File Systems
  10. 10. File systemsA file is a collection of information that is stored in thesecondary storage. Files can be programs , data, secuencebits, bytes, lines, etc.Files can store different information like programs, objectprograms, executable programs, numerical data, text, registers,images, sounds, etc.File attributes: ● Name ● Type ● Location ● Size ● Protection ● Time, date and user identification
  11. 11. File operations● Create a file● Write a file● Read a file● Relocate inside a file● Delete a file● Cut a file
  12. 12. Access MethodsThere are several ways that allow programs to access files.Sequential access.Open the file, read or write on it from beginning to end. Process an order, oneregister after another
  13. 13. Direct accessDirect access specify the starting adress of the information. Allowsrandom access to any block of the file, it is a numbered sequence ofblocks and registers.A direct access file allows to read or write arbitriary blocks, there areno restrictions about the order or reading and writing.Other methodIndexed access. Classify files by identifier (for example name),then recover the record associated with name.
  14. 14. File systemsFile systems structure stored information in a storage unit,which is represented by a file manager in the form of text or agraphStorage devices are used to allow data access like a chain ofblocks of the same size, this blocks consist of data users add intheir files. This blocks are also called sectors, their usual size is512 bytes.
  15. 15. Without a file system programs cannot be able to access databy file name or directory and we would need to be able todirectly access data regions on a storage device.File systems are used on data storage devices such asmagnetic storage disks or optical discs to maintain the physicallocation of the computer files.
  16. 16. Directory operations ● Search a file ● Create a file ● Eliminate a file ● List a directory ● Change name of a file ● Travel filesystemFile protection is important and necessary because peoplewant to share files but not all aspects of all files. Unix havethree operations for files: read, write and execute. Files have anowner and a group. For each of this operation there areprotections on basis of everybody, group and owner.
  17. 17. PseudocodeHash tableregistro par { llave, valor } function asignar(llave, valor) {var vector de pares casilla[0..numcasillas-1] i := buscacasilla(llave)function buscacasilla(llave) { if casilla[i] está ocupada i := hash(llave) módulo de numcasillas loop { casilla[i].valor := valor if casilla[i] esta libre or casilla[i].llave =llave else { return i if tabla casi llena { i := (i + 1) módulo de numcasillas } hacer tabla más grande} (nota 1)function busqueda(llave) i := buscacasilla(llave) i := buscacasilla(llave) if casilla[i] está ocupada // llave está en }la tabla return casilla[i].valor casilla[i].llave := llave else // llave no está en la casilla[i].valor := valortabla return no encontrada } }