Working with the Unix OS

Working with the Unix OS

UNIVERSITY OF ATHENS DEPARTMENT OF INFORMATICS & TELECOMMUNICATIONS WWoorrkkiinngg wwiitthh tthhee UUnniixx OOSS Maria Fragouli Dimitris Leventis Argyris Petropoulos Alex Delis AN INTRODUCTION TO UNIX CONTENTS 1. INTRODUCTION TO UNIX .................................................................................... 1 2. UNIX SHELLS.......................................................................................................18 3. C PROGRAMMING ...............................................................................................25 4. UNIX TOOLS ........................................................................................................38 5. DEVELOPMENT TOOLS.......................................................................................51 6. C LIBRARIES........................................................................................................64 7. INTRODUCTION TO KERNEL ..............................................................................80 8. PROCESSES (I) .....................................................................................................93 9. PROCESSES (II) ..................................................................................................122 10. I/O SUBSYSTEM ...............................................................................................143 11. INTERPROCESS COMMUNICATION ................................................................153 12. PROCESS SCHEDULING...................................................................................169 13. BUFFER CACHE ...............................................................................................180 14. UNIX ADMINISTRATION .................................................................................187 15. UNIX SECURITY ..............................................................................................200 TABLE OF FIGURES Figure 1. Data Structures for Processes................................................................................ 85 Figure 2. Process States and Transitions .............................................................................. 85 Figure 3. Sample Code Creating Doubly linked List ............................................................ 85 Figure 4. Incorrect Linked List because of Context Switch .................................................. 86 Figure 5.Multiple Processes Sleeping on a Lock .................................................................. 86 Figure 6. Process State ........................................................................................................ 99 Figure 7. Processes and Regions........................................................................................ 100 Figure 8. Mapping Virtual Addresses ................................................................................ 101 Figure 9. Changing Mode from User ................................................................................. 101 Figure 10. Memory Map of u area in the Kernel ................................................................ 101 Figure 11. Components of Context of a Process................................................................. 102 Figure 12. Sample Interrupt Vector.................................................................................... 102 Figure 13. Handling Interrupts........................................................................................... 102 Figure 14. Example of Interrupts ....................................................................................... 103 Figure 15. Algorithm for System Calls Invocations........................................................... 103 Figure 16. Stack configuration for creat system call........................................................... 103 Figure 17. Steps for a Context Switch................................................................................ 103 Figure 18. Pseudo-Code for Context Switch ...................................................................... 103 Figure 19. Process system calls.......................................................................................... 104 Figure 20. Algorithm for fork ............................................................................................ 104 Figure 21. Fork Creating New Process Context.................................................................. 105 Figure 22. Example of Parent and Child Share File A ........................................................ 105 Figure 23. Use of Pipe, Dup and Fork................................................................................ 106 Figure 24. Checking and Handling Signals ........................................................................ 107 Figure 25. Recognizing Signals ......................................................................................... 107 Figure 26. Algorithm for Handling Signals ........................................................................ 108 Figure 27. Driver Entry Points........................................................................................... 143 Figure 28. Block and Character Device Switch Tables....................................................... 143 Figure 29. Opening a Device ............................................................................................. 144 Figure 30. Closing a Device .............................................................................................. 144 Figure 31. Reading Disk Data - block & raw interface....................................................... 145 Figure 32. Data Sequence and Data Flow through Line Dicsipline..................................... 146 Figure 33. Removing characters from a Clist ..................................................................... 147 Figure 34. Placing characters on a Clist ............................................................................. 147 Figure 35. Writing Data to a Terminal ............................................................................... 148 Figure 36. Flooding Standard Output with Data................................................................. 148 Figure 37. Algorithm for Reading a Terminal ........................................................................1 Figure 38. Contending for Terminal Input Data ................................................................. 149 Figure 39. Raw Mode - Reading 5 character Bursts ........................................................... 150 Figure 40. Polling a Terminal ............................................................................................ 150 Figure 41. Loggin in.......................................................................................................... 151 Figure 42. A Stream after Open......................................................................................... 151 Figure 43. Pushing a Module onto a Stream....................................................................... 152 Figure 44. Windowing VT................................................................................................. 152 Figure 45. Pseudo-code for Multiplexing Windows ........................................................... 152 Figure 46. Process Scheduling........................................................................................... 170 Figure 47. Range of Process Priorities ............................................................................... 171 Figure 48. Process Scheduling Example ............................................................................ 171 Figure 49. Tie breaker rule ................................................................................................ 173 Figure 50. Fair Share Scheduler......................................................................................... 173 Figure 51. Program Using Timer ....................................................................................... 174 Figure 52. Alarm Call........................................................................................................ 174 Figure 53. Clock Handler .................................................................................................. 175 Figure 54. Invoking Profil system call ............................................................................... 175 Figure 55. Output for Profil Program................................................................................. 175 Figure 56. Algorithm for Allocating Space from Maps ...................................................... 176 Figure 57. Mapping Process Space .................................................................................... 177 Figure 58. Swapping a Process into Memory ..................................................................... 177 Figure 59. Adjusting Memory Map for Expansion Swap.................................................... 177 Figure 60. Algorithm for Swapper ..................................................................................... 178 Figure 61. Thrashing due to Swapping............................................................................... 179 Figure 62. Sequence of Swapping Operations.................................................................... 179 Figure 63. Free List of Buffers .......................................................................................... 180 Figure 64. Buffers on the Hash Queues.............................................................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    212 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us