TAILIEUCHUNG - the ansi c programming phần 8

Nhưng nó lại không có hệ điều hành; do đó, họ viết một hệ điều hành. Tiếp tục, họ quyết định để xuất hệ điều hành này sang PDP-11 của văn phòng nhưng việc này thật khó vì tất cả mã đều là ngôn ngữ Assembly. Họ quyết dịnh dùng một ngôn ngữ dể xuất cấp cao để hệ điều hành có thể xuất được dễ dàng từ máy tính này sang máy khác. Họ đã tìm đén ngôn ngữ B, nhưng nó lại thiếu các chức năng để khai thác một số khả năng của PDP-11. Vậy nên họ. | 148 Finally readdir uses read to read each directory entry. If a directory slot is not currently in use because a file has been removed the inode number is zero and this position is skipped. Otherwise the inode number and name are placed in a static structure and a pointer to that is returned to the user. Each call overwrites the information from the previous one. include sys local directory structure readdir read directory entries in sequence Dirent readdir DIR dp struct direct dirbuf local directory structure static Dirent d return portable structure while read dp- fd char dirbuf sizeof dirbuf sizeof dirbuf if 0 slot not in use continue strncpy DIRSIZ DIRSIZ 0 ensure termination return d return NULL Although the fsize program is rather specialized it does illustrate a couple of important ideas. First many programs are not ÁÁsystem programs they merely use information that is maintained by the operating system. For such programs it is crucial that the representation of the information appear only in standard headers and that programs include those headers instead of embedding the declarations in themselves. The second observation is that with care it is possible to create an interface to system-dependent objects that is itself relatively systemindependent. The functions of the standard library are good examples. Exercise 8-5. Modify the fsize program to print the other information contained in the inode entry. Example - A Storage Allocator In Chapter 5 we presented a vary limited stack-oriented storage allocator. The version that we will now write is unrestricted. Calls to malloc and free may occur in any order malloc calls upon the operating system to obtain more memory as necessary. These routines illustrate some of the considerations involved in writing machine-dependent code in a relatively machine-independent way and also show a real-life application of structures unions and typedef. Rather

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.