cs4513
play

CS4513 Process capacit y rest rict ed t o vmem size When process t - PDF document

Mot ivat ion Processes st ore, ret rieve inf ormat ion CS4513 Process capacit y rest rict ed t o vmem size When process t erminat es, memory lost Dist ribut ed Comput er Mult iple processes share inf ormat ion Syst ems


  1. Mot ivat ion • Processes st ore, ret rieve inf ormat ion CS4513 • Process capacit y rest rict ed t o vmem size • When process t erminat es, memory lost Dist ribut ed Comput er • Mult iple processes share inf ormat ion Syst ems • Requirement s: – large File Syst ems Solut ion? File – persistent Syst em! – concurrent access File Syst ems File Syst em Concept s • Abst ract ion t o disk (convenience) • Files - st ore t he dat a – “The only t hing f r iendly about a disk is t hat • Direct ories - or ganize f iles it has persist ent st orage.” • Par t it ions - separat e collect ions of – Devices may be dif f er ent : t ape, I DE/ SCSI , direct ories (also called “volumes”) NFS – all direct ory inf ormat ion kept in part it ion • Users – mount f ile syst em t o access – don’t car e about det ail • Pr ot ect ion - allow/ rest rict access f or f iles, – car e about int er f ace • OS direct ories, part it ions – cares about implement at ion (ef f iciency) Out line Files: The User’s Point of View • Naming: how do I ref er t o it ? ← ← • Files – blah, BLAH, Blah – User’s point of view – f ile.c, f ile.com – Example “Under t he Hood” • St ruct ure: what ’s inside? – File syst em implement at ion • Direct ories – Sequence of byt es (most modern OSes) • Disk space management – Records - some int er nal st r uct ur e • Misc – Tree - or ganized r ecor ds 1

  2. Files: The User’s Point of View File Operat ions • Type: • Creat e • Seek - f or r andom access – ascii - human readable • Delet e • Get at t r ibut es – binary - comput er only readable • Tr uncat e • Set at t r ibut es – “magic number” or ext ension (execut able, c-f ile … ) • Open • Access Met hod: • Read – sequent ial (f or charact er f iles, an abst ract ion of • Writ e I / O of serial device such as a modem) – random (f or block f iles, an abst ract ion of I / O t o • Append block device such as a disk) • At t ribut es: – t ime, prot ect ion, owner, hidden, lock, size ... Example: Unix open() Unix open() - Under t he Hood int fid = open(“blah”, flags); int open(char *path, int flags [, int mode]) read(fid, …); User Space • path is name of f ile Syst em Space • flags is bit map t o set swit ch – O_RDONLY, O_WRONLY… stdin 0 stdout 1 – O_CREATE t hen use mode f or per ms ... 2 stderr • on success, ret urns index 3 File File Structure • on f ailure, ret urns -1 Descriptor ... ... (where blocks are) (index) (at t ribut es) (P er process) (P er device) Example: Windows CreateFile() File Syst em I mplement at ion • Ret urns f ile obj ect handle: P rocess Open File File Descript or Disk Cont rol Block Table Table HANDLE CreateFile ( lpFileName, // name of file File sys info dwDesiredAccess, // read-write Copy f d File dwShareMode, // shared or not to mem descriptors Open lpSecurity, // permissions File Directories ... P oint er Ar r ay ) • File obj ect s used f or all: f iles, (in memory (per process) Data direct ories, disk drives, port s, pipes, copy, one per socket s and console device) Next up: f ile descr ipt or s! 2

  3. Cont iguous Allocat ion File Syst em I mplement at ion • St ore f ile as cont iguous block – ex: w/ 1K block, 50K f ile has 50 consecut ive • Which blocks wit h which f ile? blocks • File descript or implement at ions: File A: start 0, length 2 File B: start 14, length 3 – Cont iguous • Good: – Linked List – Easy: remember locat ion wit h 1 number – Linked List wit h I ndex – Fast : r ead ent ir e f ile in 1 oper at ion (lengt h) • Bad: – I -nodes – St at ic: need t o know f ile size at creat ion File • or t ough t o grow! Descriptor – Fr agment at ion: r emember why we had paging? Linked List Allocat ion Linked List Allocat ion wit h I ndex • Keep a linked list wit h disk blocks Physical null null Block File File File File File • Table in memory 0 Block Block Block Block Block – f ast er random access 0 1 2 0 1 1 P hysical – can be large! 2 null 4 7 2 6 3 Block • 1k blocks, 500MB disk 3 null • Good: • = 2MB! 4 7 – Easy: r emember 1 number (locat ion) – Windows: 5 – Ef f icient : no space lost in f r agment at ion • MS-DOS FAT 6 3 • Bad: • Win98 VFAT 7 2 – Slow: r andom access bad I -nodes Out line single i-node indir ect block • Fast f or small • Files at t r ibut es (done) f iles • Can hold big f iles ← ← • Direct ories Disk blocks • Size? • Disk space management – 4 kbyt e block • Misc double indir ect block (t r iple indir ect Block) 3

  4. Dir ect or ies Dir ect or ies • J ust like f iles, only have special bit set so you cannot modif y t hem ( what ? ) • Bef ore reading f ile, must be opened – dat a in dir ect or y is inf or mat ion / links t o • Direct ory ent ry provides inf ormat ion t o f iles – modif y t hrough syst em call get blocks – (See ls.c sample) – disk locat ion (block, address) • Organized f or: – i-node number – ef f iciency - locat ing f ile quickly • Map ascii name t o t he f ile descript or – convenience - user pat t er ns • gr oups (.c, .exe ), same names • Tree st ruct ure direct ory t he most f lexible – aliases allow f iles t o appear at mor e t han one locat ion (mor e on t his lat er ) Simple Dir ect or y Hierarchical Direct ory (MS-DOS) • No hierarchy (all “root ”) • Tree • Ent ry • Ent r y: – name – name - dat e – block count – t ype (ext ension) - block number (w/ FAT) – block numbers – t ime name block count block number s name type attrib time date block size (What are t he drawbacks?) Hierarchical Direct ory (Unix) Unix Direct ory Example Root Direct ory Block 132 Block 406 • Tree 1 . 6 . I -node 6 I -node 26 26 . • Ent r y: 1 .. 1 .. 6 .. 4 bin 26 bob 12 grants – name 7 dev 17 jeff 81 books – inode number (t r y “ ls –I ” or “ ls –iad . ”) 14 lib 14 sue 132 406 60 mbox • example: 9 etc 51 sam 17 Linux 6 usr 29 mark /usr/bob/mbox 8 tmp Aha! Looking up I -node 60 Looking up bob gives has cont ent s Relevant usr gives I -node 26 /usr/bob is of mbox dat a ( /usr ) inode name I -node 6 in block 406 is in block 132 4

  5. St oring Files I ssues • a) Dir ect or y ent r y cont ains disk blocks? – cont ent s (blocks) may change (Not r eally a C B • b) Dir ect or y ent r y point s t o f ile descr ipt or ? t ree - Direct ed Acyclic – if removed, ref ers t o non-exist ent f ile Graph) B B – must keep count , remove only if 0 B ? – hard link “alias” – Similar if delet e f ile in use (show example) • • c) Have new t ype of f ile “link”? What if … – cont ains alt ernat e name f or f ile a) Direct ory ent ry cont ains disk blocks? – overhead, must parse t ree second t ime b) Direct ory ent ry point s t o f ile descript or? – sof t link c) Have new t ype of f ile “link”? – of t en have max link count in case loop (show example) Out line Disk Space Management • n byt es • Files (done) – cont iguous • Direct ories (done) – blocks • Similar it ies wit h memor y management ← ← • Disk space management – cont iguous is like variable-sized part it ions • Misc • but moving on disk very slow! • so use blocks – blocks are like paging • how t o choose block size? • (Not e, disk block size t ypically 512 byt es, but f ile syst em logical block size chosen when f or mat t ing) Choosing Block Size Keeping Tr ack of Fr ee Blocks • Two met hods • Large blocks (not e, t hese ar e – linked list of disk blocks st or ed on t he disk) – f ast er t hr oughput , less seek t ime • one per block or many per block – wast ed space (int ernal f ragment at ion) – bit map of disk blocks • Small blocks • Linked List of Free Blocks (many per block) – less wast ed space – 1K block, 16 bit disk block number – more seek t ime since more blocks = 511 f r ee blocks/ block • 200 MB disk needs 400 f ree blocks = 400k Disk Space • Bit Map Utilization • 200 MB disk needs 20 Mbit s • Wit h linked list , 30 blocks = 30k Data Rate • 1 bit vs. 16 bit s Block size 5

Recommend


More recommend