Lines Matching full:the

4 .\" modification, are permitted provided that the following conditions are
7 .\" Redistributions of source code and documentation must retain the above
8 .\" copyright notice, this list of conditions and the following
11 .\" Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
16 .\" must display the following acknowledgement:
19 .\" International, Inc. Neither the name of Caldera International, Inc.
20 .\" nor the names of other contributors may be used to endorse or promote
24 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
26 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 .\" OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
35 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .EH 'PSD:3-%''The UNIX I/O System'
38 .OH 'The UNIX I/O System''PSD:3-%'
47 This paper gives an overview of the workings of the UNIX\(dg
54 and is oriented more toward describing the environment
55 and nature of device drivers than the implementation
56 of that part of the file system which deals with
59 It is assumed that the reader has a good knowledge
60 of the overall structure of the file system as discussed
61 in the paper ``The UNIX Time-sharing System.''
68 conjunction with a copy of the system code,
84 blocks can be written only at the end of the tape.
93 more work must be done by the driver itself.
101 with the minor device number
102 in the low-order 8 bits and the major device number
103 in the next-higher 8 bits;
110 the device; the minor device number is not used
111 by the rest of the system but is passed to the
113 Typically the minor number
131 The first of these is the
134 which is stored in the system's per-process
138 the file descriptor returned by the
146 or other operation on the open file.
148 a pointer to the corresponding
149 entry of the
153 There is one entry in the
160 This table is per-system because the same instance
161 of an open file must be shared among the several processes
164 after the file is opened.
168 flags which indicate whether the file
171 using the entry have terminated or closed the file
172 (so the entry can be abandoned).
174 which is used to indicate where in the file the next read
176 Finally, there is a pointer to the
177 entry for the file in the
180 which contains a copy of the file's i-node.
189 An entry in the
195 if the same file is opened several times,
200 in the
203 Also, a file may enter the
206 but also because it is the current directory
211 An entry in the
213 table differs somewhat from the
214 corresponding i-node as stored on the disk;
216 and the entry is augmented
217 by a flag word containing information about the entry,
220 and the device and i-number
221 whence the entry came.
222 Also, the several block numbers that give addressing
223 information for the file are expanded from
224 the 3-byte, compressed format used on the disk to full
228 During the processing of an
233 the system always calls the device's
241 routine is called only when the last
243 that is, when the i-node table entry
258 and the
260 table entry are used to set up the
266 which respectively contain the (user) address
267 of the I/O target area, the byte-count for the transfer,
268 and the current location in the file.
269 If the file referred to is
270 a character-type special file, the appropriate read
272 for transferring data and updating the
275 Otherwise, the current location is used to calculate
276 a logical block number in the file.
277 If the file is an ordinary file the logical block
281 This mapping is performed by the
284 In any event, the resulting physical block number
286 read or write the appropriate device.
292 table specifies the interface routines present for
296 (to implement the
300 If a call on the routine
318 structure also contains a pointer to the
320 structure associated with the terminal.
324 routine is called each time the file
325 is opened with the full device number as argument.
327 non-zero only if the device is to be written upon.
331 routine is called only when the file
332 is closed for the last time,
333 that is when the very last process in
334 which the file is open closes it.
335 This means it is not possible for the driver to
337 The first argument is the device number;
339 if the file was open for writing in the process which
340 performs the final
345 is called, it is supplied the device
350 the number of characters indicated by the user;
354 is the address supplied by the user from which to start
356 The system may call the
357 routine internally, so the
365 refers to the system address space instead of
373 characters from the user's buffer to the device,
381 from the user's buffer.
395 buffer may also use the routine
401 characters into the
405 bytes from the start of the buffer;
409 (which is 0) in the write case.
428 To return characters to the user, the routine
433 and returns \(mi1 as the last character
436 is returned to the user;
443 but the same cautions apply.
446 is invoked by the
454 is a pointer to the device's routine,
456 is the device number,
460 In the
464 into the vector; this will be returned to the caller.
465 In the
478 on the devices's interrupt routine.
480 the low-order four bits of the ``new PS'' word in the
481 trap vector for the interrupt available
482 to the interrupt handler.
485 to encode the minor device number.
486 After the interrupt has been processed,
487 a return from the interrupt handler will
488 return from the interrupt itself.
493 to buffer characters in the internal interface
496 For relatively low data-rate devices, the best mechanism
497 is the character queue maintained by the
502 A queue header has the structure
510 A character is placed on the end of a queue by
514 is the character and
516 is the queue header.
518 to put the character, 0 otherwise.
519 The first character on the queue may be retrieved
522 which returns either the (non-negative) character
523 or \(mi1 if the queue is empty.
525 Notice that the space for characters in queues is
526 shared among all devices in the system
527 and in the standard system there are only some 600
534 to device handlers is the sleep-wakeup mechanism.
537 causes the process to wait (allowing other processes to run)
538 until the
541 at that time, the process is marked ready-to-run
542 and the call will return when there is no
548 indicates that the
551 on the event to be awakened.
555 by the sleeper and the waker-up.
556 By convention, it is the address of some data area used
557 by the driver, which guarantees that events
561 that the event has really happened;
562 they should check that the conditions which
569 at priority less than the parameter
577 On the other hand, calls to
580 may never return if the process is terminated by
581 some signal in the meantime.
584 in a routine called at interrupt time, since the process
585 which is running is almost certainly not the
587 Likewise, none of the variables in the user area
602 by the clock interrupt routine.
607 set the processor priority level as indicated to avoid
608 inconvenient interrupts from the device.
616 sixtieths of a second, the
620 as argument, in the style
626 read the 201 Dataphone
630 Notice that the number of sixtieths of a second is limited to 32767,
634 Also, the specified
637 conform to the requirements of interrupt routines
644 the images of blocks of data on the various devices.
646 that several processes that access the same block of the same
648 view of the data in the block.
650 the efficiency of the system by
653 The main data base for this mechanism is the
659 of the buffers associated with a particular
669 also contains the device and block number to which the
670 buffer refers, and a pointer to the actual storage associated with
673 which is the negative of the number of words
674 to be transferred to or from the buffer;
679 with bits indicating the status of the buffer.
683 the most important part of the interface with the
684 rest of the system.
690 return a pointer to a buffer header for the block;
693 is guaranteed to return a buffer actually containing the
694 current data for the block,
697 returns a buffer which contains the data in the
699 or not is indicated by the
702 In either case the buffer, and the corresponding
711 still, no other process can be allowed to refer to the block
712 until the new data is placed into it.
719 but takes as an additional argument the number of
720 a block (on the same device) to be read asynchronously
721 after the specifically requested block is available.
727 makes the buffer again available to other processes.
733 and all of which logically release the buffer for
734 use by others and place it on the free list.
736 puts the
737 buffer on the appropriate device queue,
738 waits for the write to be done,
739 and sets the user's error flag if required.
741 places the buffer on the device's queue, but does not wait
748 to be grabbed from the free list to contain
749 data from some other block, the data in it will
756 errors are reflected to the proper user;
761 but when it is reasonably certain that the
764 is used when there is doubt that the write is
765 needed at the moment.
768 is called when the last byte of a
770 system call falls short of the end of a
771 block, on the assumption that
774 will be given soon which will re-use the same block.
775 On the other hand,
776 as the end of a block is passed,
778 is called, since probably the block will
780 well start the writing process as soon as possible.
782 In any event, notice that the routines
786 dedicate the given block exclusively to the
787 use of the caller, and make others wait,
792 must eventually be called to free the block for use by others.
795 word which indicates the status of the buffer.
797 one important channel for information between the drivers and the
800 select the associated flag bits.
802 This bit is set when the buffer is handed to the device strategy routine
813 to 0 when a block is handed to the device strategy
814 routine and is turned on when the operation completes,
815 whether normally as the result of an error.
816 It is also used as part of the return argument of
818 to indicate if 1 that the returned
819 buffer actually contains the data in the requested block.
824 If it is set the
826 byte of the buffer header may contain an error code
830 is 0 the nature of the error is not specified.
837 This bit indicates that the buffer header is not on
840 The buffer still remains attached to the list of
846 which calls it) searches the buffer list
847 for a given device and finds the requested
848 block with this bit on, it sleeps until the bit
852 need to allocate the Unibus map on an 11/70.
854 This bit is set on buffers that have the Unibus map allocated,
855 so that the
857 routine knows to deallocate the map.
859 This flag is used in conjunction with the
866 Conversely, when the block is freed and the busy bit
871 is given for the block header whenever
874 This strategem avoids the overhead
877 every time a buffer is freed on the chance that someone
882 the buffer is placed at the head of the free list, rather than at the
885 used when the caller judges that the same block will not soon be used again.
889 to indicate to the appropriate device driver
890 that the buffer should be released when the
896 is that the former starts I/O, waits until it is done, and
897 frees the buffer.
901 should be called for the buffer on completion.
905 before releasing the buffer.
909 discovers the bit is 1 in a buffer it would otherwise grab,
910 it causes the block to be written out before reusing it.
916 table contains the names of the interface routines
925 called respectively on each open and on the final close
926 of the device.
932 As discussed, the buffer header contains
933 a read/write flag, the core address,
935 and the major and minor device number.
936 The role of the strategy routine
937 is to carry out the operation as requested by the
938 information in the buffer header.
939 When the transaction is complete the
941 (and possibly the
944 Then if the
951 In cases where the device
955 in the residual count slot of
957 otherwise, the residual count should be set to 0.
958 This particular mechanism is really for the benefit
959 of the magtape driver;
962 and the user should be told the actual length of the record.
964 Although the most usual argument
965 to the strategy routines
968 is that the argument be a pointer to a place containing the
970 For example the
973 of core images to and from the swapping device,
974 uses the strategy routine
977 no extraneous bits get turned on in the
984 a pair of links which constitute the
985 head of the chain of buffers for the device
988 Of these things, all are used solely by the device driver
990 except for the buffer-chain pointers.
991 Typically the flag encodes the state of the
993 indicate that the device is currently engaged in
998 in the simplest case it may be maintained as a first-in
1002 on the list of free buffers,
1003 the pointers in the buffer which maintain the free list
1005 are also used to contain the pointers
1006 which maintain the device queues.
1011 arranges that the buffer to which
1015 when the
1016 strategy module has finished with the buffer,
1018 (In the latter case the
1024 can be used to examine the error bit in a buffer header
1026 reflected to the user.
1027 It may be called only in the non-interrupt
1035 provide the ability to transfer information
1036 directly between the user's core image and the device
1037 without the use of buffers and in blocks as large as
1040 corresponding to the raw device
1046 non-shared buffer header with the appropriate information
1047 and call the device's strategy routine.
1056 A great deal of work has to be done to generate the
1058 to put in the argument buffer for
1063 whose arguments are the name of the
1077 makes sure that the user's base address and count are
1079 and that the core area affected is contiguous
1081 it delays until the buffer is not busy, and makes it
1082 busy while the operation is in progress;