标题:老师布置了个文件管理的编程作业..达人们来帮忙下啊..
取消只看楼主
20021017
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-12-12
 问题点数:0 回复次数:0 
老师布置了个文件管理的编程作业..达人们来帮忙下啊..
老师布置了个文件管理的编程作业..达人们来帮忙下啊..
在下面有中文翻译......请耐心点拉下去吧...谢谢
Locality and paging
Design a file management program. The program is used to manage a potentially very large file that cannot fit into memory. It will allocate a limited amount of main memory to hold pieces of data from the file. The data on memory may need to be written to disk if modified when the memory is on demand.
Please implement the following API functions in C:
1. int cacheRead(long start, int len, char *buf);
This function will copy a chunk of data from cache to a destination buffer. If the data is not yet on the memory cache, you need to bring the data into the cache first. The first parameter is the offset of the data on the file.
2. int cacheWrite(long start, int len, char *buf);
This function will write the data on the buffer to the cache. The data will need to be eventually made to the file when program exits.
3. int cacheOpen(char *filename);
This function will open the cache and dedicate it to the file specified.
4. int cacheClose(int file);
This function will close the cache related to the file.

Hint: You may need to have a modification flag for each cache page (see below).

1. You can allocate a data cache in the main memory using malloc() or other memory allocation functions. The cache size of memory must be 8MB (no more, no less).
2. The 8MB cache is divided into 1024 pages, each page is of 8KB in size.
3. You can decide the strategy of page replacements. A carefully designed strategy will greatly increase the performance of your program.
4. The performance of your program will be determined by the HIT RATIO.
5. The program should not directly or indirectly invoke any file access functions, instead it must call the following functions to access file: mRead(); mWrite(); mOpen(); mClose().
6. The mRead() and mWrite() will read/write a page of data from/to the disk. The page size is predetermined as 8KB.  

中文翻译....用在线翻译弄的....翻得有点差....
设计文件管理
设计一个档案管理程式。该计划是用来管理一个潜在的非常大的文件,可以不适合到内存中。这将投放数量有限的主内存举行件的数据档案。数据存储器可能要写信给磁盘,如果修改时,内存是用户需求。
请执行以下api函数在c :
1 。 int cacheRead(long start, int len, char *buf);
此功能将拷贝一大块的数据从缓存到一个目的地的缓冲区。如果数据尚未对快取记忆体,你必须把数据写入缓存第一次。第一个参数是偏移的数据档案。
2 。 int cacheWrite(long start, int len, char *buf);
此功能将写入数据的缓冲区,以快取记忆体中。这些数据将需要得到最终作出档案时,计划出口。
3 。 int cacheOpen(char *filename);
此功能将打开缓存和奉献的精神,它向指定的文件。
4 。 int cacheClose(int file);
此功能将关闭缓存相关档案。

提示:你可能需要有一个国旗修改为每缓存页(见下文) 。

1 。你可以拨出一个数据高速缓存,在主记忆体使用的malloc ( )或其他内存分配职能。缓存大小的记忆必须含8mb (没有更不会少) 。
2 。该含8mb缓存分为1024页,每一页,是8 kb的大小。
3 。你可以决定战略页的替代产品。一个精心设计的策略,将大大增强,履行自己的计划。
4 。履行自己的计划,将取决于命中率。
5 。该计划不应该直接或间接地援引任何档案存取功能,而不是它必须调用下列功能,以获取档案: mread ( ) ; mwrite ( ) ; mopen ( ) ; mclose ( ) 。
6 。该mread ( )和mwrite ( )将读/写了一页的数据从/向磁盘。页面大小是预定为8 kb的。




第2部分...
Project 2.  Multithreading and Concurrency.多处理器与并发

Let’s assume that the program you implemented in the project #1 is to be used by other applications.  In a typical situation, the program is compiled into a DLL, and another program links to the DLL and creates multiple threads, each of which will call your API functions independently.  In such situations, you need to lock your data to prevent corruption.  假设你在设计1执行的程序是 应用别的应用软件,,在一典型的情况下,这程序编译成一个动态连接库,另一程序连接到动态连接库,然后创建多头螺纹,每个都会独立地命令你的应用编程接口运行,在这种情况下,你需要锁定数据去维护你的讹误

Please add necessary locks in the API functions you implemented in the project #1:
请在你运行的第一个项目中的应用编程接口中加上一些必要的封闭口
1. int cacheRead(long start, int len, char *buf);

2. int cacheWrite(long start, int len, char *buf);

3. int cacheOpen(char *filename);

4. int cacheClose(int file);
搜索更多相关主题的帖子: 文件管理 作业 memory 老师 The 
2007-12-12 14:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-192047-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.452818 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved