操作系统课程设计
大学生操作系统课程设计

大学生操作系统课程设计一、教学目标本课程的教学目标分为三个维度:知识目标、技能目标和情感态度价值观目标。
1.知识目标:通过本课程的学习,学生需要掌握操作系统的基本概念、原理和关键技术,包括进程管理、内存管理、文件系统和输入/输出系统等。
2.技能目标:培养学生具备操作系统实验操作和程序设计的能力,能够运用所学知识分析和解决实际问题。
3.情感态度价值观目标:培养学生对操作系统学科的兴趣和热情,培养学生的创新意识和团队合作精神。
二、教学内容本课程的教学内容主要包括操作系统的基本概念、原理和关键技术。
1.教材章节:(1)引言和概述(2)进程管理(3)内存管理(4)文件系统(5)输入/输出系统(6)并发程序设计(7)操作系统安全与保护2.具体内容:(1)操作系统的定义、作用和分类(2)进程的基本概念、状态和控制(3)进程同步与互斥(4)死锁与饥饿(5)内存分配与回收策略(6)虚拟内存技术(7)文件和目录结构(8)文件访问控制和保护(9)输入/输出管理(10)操作系统用户接口三、教学方法本课程采用多种教学方法相结合,以提高学生的学习兴趣和主动性。
1.讲授法:用于传授基本概念、原理和方法。
2.讨论法:鼓励学生积极参与课堂讨论,培养学生的思考和分析能力。
3.案例分析法:通过分析实际案例,使学生更好地理解和掌握操作系统原理。
4.实验法:培养学生动手实践能力,巩固所学知识。
四、教学资源1.教材:选用国内外优秀教材,如《操作系统概念》、《现代操作系统》等。
2.参考书:提供相关领域的参考书籍,丰富学生的知识体系。
3.多媒体资料:制作课件、教学视频等,提高课堂教学效果。
4.实验设备:配置充足的实验设备,确保学生能够充分进行实践操作。
五、教学评估本课程的教学评估采用多元化的评价方式,包括平时表现、作业、考试等,以全面客观地评价学生的学习成果。
1.平时表现:通过课堂参与、提问、讨论等方式,评估学生的学习态度和思考能力。
2.作业:布置适量的作业,评估学生对知识点的理解和运用能力。
windows操作系统核心编程实验教程课程设计

Windows操作系统核心编程实验教程课程设计一、课程概述本教程是针对操作系统核心编程(Windows)进行的实验课程设计,旨在为计算机科学与技术专业学生提供系统化的操作系统编程实践经验以及对Windows操作系统的进一步了解。
通过实验,学生将学习到操作系统的核心概念、体系结构、功能模块以及编程接口。
本教程适合计算机科学与技术专业的本科生、研究生的操作系统和计算机系统课程。
二、教学目标1.深入了解Windows操作系统的内部结构、设计原理及运行机制。
2.掌握操作系统核心概念、体系结构和功能模块。
3.掌握Windows操作系统的编程接口、开发技术、基本工具及其使用方法。
4.掌握Windows操作系统资源管理(如内存管理、进程管理、线程管理等)及其编程方法。
5.提高学生的系统编程能力和应用能力。
三、教学内容与大纲1.章节一:操作系统介绍–操作系统概述–操作系统的发展历程、种类及类别–Windows操作系统介绍2.章节二:操作系统架构–操作系统的体系结构–Windows操作系统的体系结构–操作系统模式(内核模式和用户模式)3.章节三:进程管理–进程概念–进程状态和状态转换–进程控制块–进程调度–进程同步与通信实现(如互斥量、信号量、管道等)–进程编程实践4.章节四:线程管理–线程概念和状态转换–线程控制块–线程同步与通信实现–线程编程实践5.章节五:内存管理–内存概述和内存分区–虚拟存储器和页面交换–内存管理实现(页式管理、段式管理)–内存编程实践6.章节六:设备管理–设备管理概述–Windows I/O管理模型–设备驱动程序开发–设备编程实践四、教学方法采用课堂讲授和实践操作相结合的教学方法,注重培养学生的动手能力和创新意识。
主讲教师将通过讲解操作系统原理和编程知识,来进行基础理论的传授,同时也会通过实践操作来加深理解,提高实际操作能力。
五、实验环境本教程主要使用Visual Studio 2017作为开发工具,配合Windows 10操作系统进行实验。
《操作系统》课程设计

《操作系统》课程设计一、课程目标知识目标:1. 让学生掌握操作系统的基本概念,包括进程、线程、内存管理、文件系统等核心知识;2. 了解操作系统的历史发展,掌握不同类型操作系统的特点及使用场景;3. 掌握操作系统的性能评价方法和常用的调度算法。
技能目标:1. 培养学生运用操作系统知识解决实际问题的能力,如分析系统性能瓶颈、优化系统资源分配等;2. 培养学生具备基本的操作系统编程能力,如进程创建、线程同步、文件操作等;3. 提高学生的团队协作能力和沟通能力,通过小组讨论和项目实践,学会共同解决问题。
情感态度价值观目标:1. 培养学生对操作系统学科的兴趣,激发学生的学习热情,使其形成积极向上的学习态度;2. 培养学生具备良好的信息素养,尊重知识产权,遵循法律法规;3. 培养学生的创新精神和批判性思维,敢于质疑、勇于探索,形成独立思考的能力。
课程性质:本课程为计算机科学与技术专业的核心课程,旨在让学生掌握操作系统的基本原理和实现方法,提高学生的系统分析和编程能力。
学生特点:学生具备一定的编程基础和计算机系统知识,具有较强的逻辑思维能力和动手实践能力。
教学要求:结合学生特点和课程性质,注重理论与实践相结合,通过案例分析和项目实践,帮助学生将所学知识内化为具体的学习成果。
在教学过程中,关注学生的学习进度和反馈,及时调整教学策略,确保课程目标的实现。
二、教学内容1. 操作系统概述:介绍操作系统的定义、发展历程、功能、类型及特点,对应教材第一章内容。
- 操作系统的起源与发展- 操作系统的功能与类型- 操作系统的主要特点2. 进程与线程:讲解进程与线程的概念、状态、调度算法,对应教材第二章内容。
- 进程与线程的定义与区别- 进程状态与转换- 进程调度算法3. 内存管理:分析内存管理的基本原理、策略和技术,对应教材第三章内容。
- 内存分配与回收策略- 虚拟内存技术- 页面置换算法4. 文件系统:介绍文件系统的基本概念、结构、存储原理,对应教材第四章内容。
操作系统概念-Java实现第七版课程设计

操作系统概念-Java实现第七版课程设计简介本文是一篇关于操作系统概念-Java实现第七版课程设计的文档。
操作系统概念是计算机科学中非常重要的一门课程,而Java是一种广泛使用的编程语言,结合二者,为学生提供了快速而有效的学习操作系统的方式。
本文将介绍如何在课程设计中使用Java实现操作系统概念。
设计目标本课程设计的主要目标是让学生掌握操作系统的基本概念和原理,并能够设计和实现简单的操作系统。
本课程设计分为两个部分:1.操作系统基本概念的学习和理解。
2.使用Java语言实现一个简单的操作系统。
设计内容操作系统基本概念的学习和理解学生需要掌握以下操作系统基本概念:1.操作系统的定义和发展历程。
2.操作系统的组成和功能。
3.进程和线程。
4.内存管理。
5.IO管理。
6.文件系统。
学生可以通过教材、PPT等渠道学习相关知识,并进行课堂讲解、案例分析和小组讨论等形式的教学,以提高学生对操作系统基本概念的掌握和理解。
使用Java语言实现一个简单的操作系统在掌握了操作系统的基本概念之后,学生需要使用Java语言实现一个简单的操作系统。
该操作系统需要包括以下功能:1.进程管理:创建进程、销毁进程、进程间的通信等。
2.内存管理:分配内存、释放内存等。
3.IO管理:读取文件、写入文件、创建文件、删除文件等。
学生可以使用Java语言编写相关代码,并进行调试和优化,以实现一个功能完整的操作系统。
设计过程本课程设计的实现过程可以分为以下几个步骤:1.学生自学操作系统基本概念。
2.学生分组进行操作系统设计和实现工作。
3.分组内成员进行相互协作,完成进程管理、内存管理和IO管理等功能模块的编写。
4.教师进行评价、检查和指导。
设计效果通过本课程设计,学生可以:1.掌握操作系统的基本概念和原理。
2.熟悉Java语言的使用。
3.获得实际操作系统设计和实现的经验。
4.培养学生的分析和解决问题的能力。
总结本文介绍了如何使用Java语言实现操作系统概念课程设计,包括课程设计目标、设计内容、设计过程和设计效果。
操作系统课程设计项目参考

滴加碘液后
滴加碘液前
12/12/2021
第十二页,共二十三页。
消化(xiāohuà):在消化道内将食物分解成可吸收 (xīshōu)的成分的过程
(包括物理性消化和化学性消化)
吸收(xīshōu):营养物质通过消化道壁进入循环 系统的过程
12/12/2021
第十三页,共二十三页。
消化(xiāohuà)和吸收的过程
12/12/2021
第十九页,共二十三页。
练习(liànxí)
• 2、分析数据,指出(zhǐ chū)哪一部分消化道中消化液最多。
• 在每天摄入800克食物和1200毫升水的情况下, 消化腺大致分泌以下数量消化液。 1500毫升唾液 2000毫升胃液 1500毫升肠液 500毫升胆汁 1500毫升胰液
12/12/2021
第二十二页,共二十三页。
内容 总结 (nèiróng)
第二节。食物中的营养物质是在消化系统中被消化和吸收的。这粒西瓜籽在姗姗的消化道内, 经过了难忘的时光。它先遇到像轧钢机似的上、下尖硬的怪物,差点儿将它压得粉身碎骨。后来它
No 钻进了一条(yī tiáo)又长又窄的迷宫,它在这里走了很久,身边的许多物质都神秘地消失了。走出迷
唾液腺、胃腺(wèixiàn)、肝脏、胰腺、肠腺
1、淀粉在__口__腔__开始消化、蛋白质在____开始胃消化、脂肪在_______开始 消小化肠。
2、胆汁是一种消化液,但不含消化酶,起乳化脂肪的作用。
二、人体消化、吸收的主要器官—— _____小肠 能 训 练解
胰脏:分泌(fēnmì)胰液 肠腺:分泌肠液
肝脏:最大的腺体,分泌胆汁。 胆汁无消化酶,有乳化脂肪 的
作用。
第七页,共二十三页。
操作系统多线程课程设计

操作系统多线程课程设计一、课程目标知识目标:1. 理解操作系统中多线程的基本概念,掌握线程的创建、同步与通信机制;2. 学会分析多线程程序的性能与问题,了解常见线程同步问题的解决方案;3. 掌握操作系统级别线程调度的基本原则和方法。
技能目标:1. 能够运用所学知识,设计并实现简单的多线程程序;2. 能够运用同步机制,解决多线程中的竞态条件和死锁问题;3. 能够对多线程程序进行性能分析,并提出优化方案。
情感态度价值观目标:1. 培养学生对操作系统多线程技术的兴趣,激发他们探索计算机科学领域的热情;2. 培养学生团队合作意识,学会在团队项目中分工与协作;3. 培养学生面对复杂问题时的分析能力、解决问题的能力和创新精神。
课程性质:本课程为计算机科学与技术专业高年级选修课,旨在帮助学生深入理解操作系统中多线程技术,提高他们解决实际问题的能力。
学生特点:学生具备一定的编程基础和操作系统基本知识,具备独立分析和解决问题的能力。
教学要求:结合实际案例,注重理论与实践相结合,提高学生的动手能力和实际应用能力。
通过课程学习,使学生能够将多线程技术应用于实际项目中,提高软件性能。
二、教学内容1. 多线程基本概念:线程的定义、线程与进程的关系、线程的创建与销毁;2. 线程同步与通信:互斥锁、条件变量、信号量、管程等同步机制,线程间通信方式;3. 线程调度:调度算法、时间片轮转、优先级调度、多级反馈队列调度等;4. 多线程程序设计:多线程编程模型、线程池、线程局部存储、多线程并发控制;5. 常见线程同步问题及解决方案:竞态条件、死锁、饥饿、活锁等;6. 性能分析与优化:多线程程序性能指标、性能瓶颈分析、优化策略;7. 实践环节:结合实际案例,设计并实现多线程程序,分析并优化性能。
教学内容依据教材相关章节组织,具体安排如下:第一周:多线程基本概念,线程创建与销毁;第二周:线程同步与通信,互斥锁、条件变量、信号量等;第三周:线程调度,调度算法;第四周:多线程程序设计,线程池、线程局部存储;第五周:常见线程同步问题及解决方案;第六周:性能分析与优化;第七周:实践环节,课程总结与展示。
操作系统课程设计pintos

操作系统课程设计pintos一、教学目标本课程的目标是让学生了解和掌握操作系统的基本原理和概念,通过学习Pintos操作系统,使学生能够理解操作系统的核心机制,包括进程管理、内存管理、文件系统和输入/输出系统等。
在技能方面,学生应能够使用Pintos进行简单的操作系统设计和实现,提升编程能力和系统分析能力。
在情感态度价值观方面,学生应培养对计算机科学和操作系统的兴趣,增强解决实际问题的责任感和使命感。
二、教学内容教学内容将按照Pintos操作系统的结构和功能进行,包括:1. 操作系统的概述和基本概念;2. 进程管理,包括进程的创建、调度和同步;3. 内存管理,包括物理内存管理和虚拟内存管理;4. 文件系统,包括文件和目录的、文件系统的实现;5. 输入/输出系统,包括设备驱动程序和中断处理。
三、教学方法为了激发学生的学习兴趣和主动性,将采用多种教学方法,包括:1. 讲授法,用于讲解操作系统的原理和概念;2. 讨论法,用于讨论操作系统的实现和应用;3. 案例分析法,通过分析具体的操作系统案例,让学生理解操作系统的实际应用;4. 实验法,通过实验操作,让学生亲手实现操作系统的核心机制。
四、教学资源教学资源包括:1. Pintos操作系统的教材和相关参考书;2. 多媒体资料,包括操作系统的教学视频和PPT;3. 实验设备,包括计算机和相关的硬件设备。
这些教学资源将用于支持教学内容和教学方法的实施,丰富学生的学习体验。
五、教学评估教学评估将采用多种方式进行,以全面、客观、公正地评价学生的学习成果。
评估方式包括:1. 平时表现,包括课堂参与、提问和讨论等,占总评的20%;2.作业,包括理论和实践作业,占总评的30%;3. 考试,包括期中考试和期末考试,占总评的50%。
考试内容将涵盖操作系统的原理、概念和实验操作。
六、教学安排教学安排将根据课程内容和学生的实际情况进行设计。
本课程计划在一个学期内完成,每周安排2次课时,每次课时1小时。
操作系统课程设计题目

-操作系统性能调优策略
-多处理器系统
-多处理器系统的基本概念
-并行与分布式计算
-实时操作系统
-实时操作系统的特点与需求
-实时调度算法
-操作系统中的并发控制
-并发的基本概念
-互斥与同步机制
-课程设计进阶项目
-设计并实现一个简单的实时操作系统
-研究并发控制策略在操作系统中的应用
-分析多处理器系统中的负载均衡问题
4.章节四:内存管理
-内存分配与回收策略
-虚拟内存与分页机制
5.章节五:设备管理
-设备管理的基本原理
- I/O调度策略
6.章节六:文件系统
-文件与目录结构
-文件存储与访问控制
2、教学内容
-文件系统性能优化
-磁盘空间分配策略
-磁盘碎片整理方法
-操作系统安全性
-访问控制机制
-加密与认证技术
-操作系统实例分析
-探索操作系统在移动设备、物联网等新兴领域的应用案例
4、教学内容
-操作系统接口与用户交互
-命令行接口(CLI)与图形用户界面(GUI)
-操作系统提供的系统调用与服务
-操作系统的网络功能
-网络协议栈的基础知识
-操作系统在网络通信中的作用
-操作系统的虚拟化技术
-虚拟化技术的原理与应用
-虚拟机监控器(VMM)的作用与分类
-探讨操作系统在人机交互方面的未来发展趋势
-评估开源操作系统的标准化程度及其对行业的影响
操作系统课程设计题目
一、教学内容
本章节内容来自《操作系统》课程,针对高二年级学生,选择以下课程设计题目:
1.章节一:操作系统概述
-操作系统Hale Waihona Puke 基本概念-操作系统的历史与发展
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
课程设计学生学院计算机学院专业班级12(1)班学号3112006351学生姓名吴炜文指导教师李敏2015年 1 月10 日目录1 简单文件系统…………………………………………………………文件系统一、实验目的:模拟文件管理的功能,了解各种文件的操作。
二、实验内容:1、设计一个10个用户的文件系统,每次用户可保存10个文件,一次运行用户可以打开5个文件2、程序采用二级文件目录(即设置主目录[MFD])和用户文件目录(UED)。
另外,为打开文件设置了运行文件目录(AFD)。
3、为了便于实现,对文件的读写作了简化,在执行读写命令时,只需改读写指针,并不进行实际的读写操作。
4、算法与框图:a、因系统小,文件目录的检索使用了简单的线性搜索。
b、文件保护简单使用了三位保护码:允许读写执行、对应位为1,对应位为0,则表示不允许读写、执行。
c、程序中使用的主要设计结构如下:i主文件目录和用户文件目录(MFD、UFD)ii 打开文件目录(AFD)(即运行文件目录)要求:用高级语言编写和调试一个简单的文件系统,模拟文件管理的工作过程。
从而对各种文件操作命令的实质内容和执行过程有比较深入的了解。
要求设计一个n个用户的文件系统,每次用户可保存m个文件,用户在一次运行中只能打开一个文件,对文件必须设置保护措施,且至少有Create、delete、open、close、read、write等命令。
文件系统算法的流程图如下:三、源代码及运行结果:#include "stdio.h"#include "string.h"#include "conio.h"#include "stdlib.h"#define MAXNAME 25 /*the largest length of mfdname,ufdname,filename*/#define MAXCHILD 50 /*the largest child*/#define MAX (MAXCHILD*MAXCHILD) /*the size of fpaddrno*/typedef struct /*the structure of OSFILE*/{int fpaddr; /*file physical address*/int flength; /*file length*/int fmode; /*file mode:0-Read Only;1-Write Only;2-Read and Write(default);*/ char fname[MAXNAME]; /*file name*/} OSFILE;typedef struct /*the structure of OSUFD*/{char ufdname[MAXNAME]; /*ufd name*/OSFILE ufdfile[MAXCHILD]; /*ufd own file*/}OSUFD;typedef struct /*the structure of OSUFD'LOGIN*/{char ufdname[MAXNAME]; /*ufd name*/char ufdpword[8]; /*ufd password*/} OSUFD_LOGIN;typedef struct /*file open mode*/{int ifopen; /*ifopen:0-close,1-open*/int openmode; /*0-read only,1-write only,2-read and write,3-initial*/}OSUFD_OPENMODE;OSUFD *ufd[MAXCHILD]; /*ufd and ufd own files*/OSUFD_LOGIN ufd_lp;int ucount=0; /*the count of mfd's ufds*/int fcount[MAXCHILD]; /*the count of ufd's files*/int loginsuc=0; /*whether login successfully*/char username[MAXNAME]; /*record login user's name22*/char dirname[MAXNAME];/*record current directory*/int fpaddrno[MAX]; /*record file physical address num*/OSUFD_OPENMODE ifopen[MAXCHILD][MAXCHILD]; /*record file open/close*/int wgetchar; /*whether getchar()*/FILE *fp_mfd,*fp_ufd,*fp_file_p,*fp_file;void main(){int i,j,choice1;char choice[50]; /*choice operation:dir,create,delete,open,delete,modify,read,write*/ int choiceend=1; /*whether choice end*/char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/void LoginF(); /*LOGIN FileSystem*/void DirF(); /*Dir FileSystem*/void CdF(); /*Change Dir*/void CreateF(); /*Create File*/void DeleteF(); /*Delete File*/void ModifyFM(); /*Modify FileMode*/void OpenF(); /*Open File*/void CloseF(); /*Close File*/void ReadF(); /*Read File*/void WriteF(); /*Write File*/void QuitF(); /*Quit FileSystem*/void help();if((fp_mfd=fopen("c:\\osfile\\mfd","rb"))==NULL){fp_mfd=fopen("c:\\osfile\\mfd","wb");fclose(fp_mfd);}for(i=0;i<MAX;i++) fpaddrno[i]=0;textattr(BLACK*16|WHITE);clrscr(); /*clear screen*/LoginF(); /*user login*/clrscr();if(loginsuc==1) /*Login Successfully*/{while (1){wgetchar=0;if (choiceend==1){printf("\n\nC:\\%s>",strupr(dirname));}else printf("Bad command or file name.\nC:\\%s>",strupr(username));gets(choice);strcpy(choice,ltrim(rtrim(strlwr(choice))));if (strcmp(choice,"dir")==0) choice1=1;else if(strcmp(choice,"creat")==0) choice1=2;else if(strcmp(choice,"delete")==0) choice1=3;else if(strcmp(choice,"attrib")==0) choice1=4;else if(strcmp(choice,"open")==0) choice1=5;else if(strcmp(choice,"close")==0) choice1=6;else if(strcmp(choice,"read")==0) choice1=7;else if(strcmp(choice,"modify")==0) choice1=8;else if(strcmp(choice,"exit")==0) choice1=9;else if(strcmp(choice,"cls")==0) choice1=10;else if(strcmp(choice,"cd")==0) choice1=11;else if(strcmp(choice,"help")==0) choice1=20;else choice1=12;switch(choice1){case 1:DirF();choiceend=1;break;case 2:CreateF();choiceend=1;if(!wgetchar) getchar();break;case 3:DeleteF();choiceend=1;if(!wgetchar)getchar();break;case 4:ModifyFM();choiceend=1;if(!wgetchar) getchar();break;case 5:choiceend=1;OpenF();if (!wgetchar) getchar();break;case 6:choiceend=1;CloseF();if (!wgetchar) getchar();break;case 7:choiceend=1;ReadF();if (!wgetchar) getchar();break;case 8:choiceend=1;WriteF();if (!wgetchar) getchar();break;case 9:printf("\nYou have exited this system.");QuitF();exit(0);break;case 10:choiceend=1;clrscr();break;case 11:CdF();choiceend=1;break;case 20:help();choiceend=1;break;default:choiceend=0;}}}else printf("\nAccess denied.");}void help(void){printf("\nThe Command List\n");printf("\nCd Attrib Creat Modify Read Open Cls Delete Exit Close\n"); }char *rtrim(char *str) /*remove the trailing blanks.*/{int n=strlen(str)-1;while(n>=0){if(*(str+n)!=' '){*(str+n+1)='\0';break;}else n--;}if (n<0) str[0]='\0';return str;}char *ltrim(char *str) /*remove the heading blanks.*/{char *rtrim(char *str);strrev(str);rtrim(str);strrev(str);return str;}void LoginF() /*LOGIN FileSystem*/{char loginame[MAXNAME],loginpw[9],logincpw[9],str[50];int i,j,flag=1;char a[25];int findout; /*login user not exist*/char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/void InputPW(char *password); /*input password,use '*' replace*/void SetPANo(int RorW); /*Set physical address num*/while(1){findout=0;printf("\n\nLogin Name:");gets(loginame);ltrim(rtrim(loginame));fp_mfd=fopen("c:\\osfile\\","rb");for(i=0;fread(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd)!=0;i++)if (strcmp(strupr(ufd_lp.ufdname),strupr(loginame))==0){findout=1;strcpy(logincpw,ufd_lp.ufdpword);}fclose(fp_mfd);if (findout==1) /*user exist*/{printf("Login Password:");InputPW(loginpw); /*input password,use '*' replace*/if (strcmp(loginpw,logincpw)==0){strcpy(username,strupr(loginame));strcpy(dirname,username);fp_mfd=fopen("c:\\osfile\\","rb");for(j=0;fread(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd)!=0;j++){strcpy(str,"c:\\osfile\\");strcat(str,ufd_lp.ufdname);ufd[j]=(OSUFD*)malloc(sizeof(OSUFD));strcpy(ufd[j]->ufdname,strupr(ufd_lp.ufdname));fp_ufd=fopen(str,"rb");fcount[j]=0;for(i=0;fread(&ufd[j]->ufdfile[i],sizeof(OSFILE),1,fp_ufd)!=0;i++,fcount[j]++){ifopen[j][i].ifopen=0;ifopen[j][i].openmode=4;}fclose(fp_ufd);}fclose(fp_mfd);ucount=j;SetPANo(0);printf("\n\nLogin successful! Welcome to this FileSystem\n\n");loginsuc=1;return;}else{printf("\n\n");flag=1;while(flag){printf("Login Failed! Password Error. Try Again(Y/N):");gets(a);ltrim(rtrim(a));if (strcmp(strupr(a),"Y")==0) {loginsuc=0;flag=0;}else if(strcmp(strupr(a),"N")==0){loginsuc=0;flag=0;return;}}} }else{printf("New Password(<=8):");InputPW(loginpw); /*input new password,use '*' replace*/printf("\nConfirm Password(<=8):"); /*input new password,use '*' replace*/InputPW(logincpw);if (strcmp(loginpw,logincpw)==0){strcpy(ufd_lp.ufdname,strupr(loginame));strcpy(ufd_lp.ufdpword,loginpw);fp_mfd=fopen("c:\\osfile\\","ab");fwrite(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd);fclose(fp_mfd);strcpy(username,strupr(loginame));strcpy(dirname,loginame);strcpy(str,"c:\\osfile\\");strcat(str,username);if((fp_ufd=fopen(str,"rb"))==NULL){fp_ufd=fopen(str,"wb");fclose(fp_ufd);}fp_mfd=fopen("c:\\osfile\\","rb");for(j=0;fread(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd)!=0;j++){strcpy(str,"c:\\osfile\\");strcat(str,ufd_lp.ufdname);ufd[j]=(OSUFD*)malloc(sizeof(OSUFD));strcpy(ufd[j]->ufdname,strupr(ufd_lp.ufdname));fp_ufd=fopen(str,"rb");for(i=0;fread(&ufd[j]->ufdfile[i],sizeof(OSFILE),1,fp_ufd)!=0;i++,fcount[j]++){ifopen[j][i].ifopen=0;ifopen[j][i].openmode=4;}fclose(fp_ufd);}fclose(fp_mfd);ucount=j;SetPANo(0);printf("\n\nLogin Successful! Welcome to this System\n\n");loginsuc=1;return;}else{printf("\n\n");flag=1;while(flag){printf("Login Failed! Password Error. Try Again(Y/N):");gets(a);ltrim(rtrim(a));if (strcmp(strupr(a),"Y")==0) {loginsuc=0;flag=0;}else if(strcmp(strupr(a),"N")==0){loginsuc=0;flag=0;return;}} } } } }void SetPANo(int RorW) /*Set physical address num,0-read,1-write*/{int i,j;if (RorW==0){if((fp_file_p=fopen("c:\\osfile\\file\\file_p","rb"))==NULL){fp_file_p=fopen("c:\\osfile\\file\\file_p","wb");fclose(fp_file_p);}fp_file_p=fopen("c:\\osfile\\file\\file_p","rb");for(i=0;fread(&j,sizeof(int),1,fp_file_p)!=0;i++)fpaddrno[j]=1;/*for(i=1;i<MAX;i++)if ((i%13)==0) fpaddrno[i]=1;*/}else{fp_file_p=fopen("c:\\osfile\\file\\file_p","wb");/*for(i=1;i<MAX;i++)if((i%13)==0) fpaddrno[i]=0;*/for(i=0;i<MAX;i++)if (fpaddrno[i]==1)fwrite(&i,sizeof(int),1,fp_file_p);}fclose(fp_file_p);}void InputPW(char *password) /*input password,use '*' replace*/{int j;for(j=0;j<=7;j++){password[j]=getch();if ((int)(password[j])!=13){if((int)(password[j])!=8)putchar('*');else{if (j>0){j--;j--;putchar('\b');putchar(' ');putchar('\b');}else j--;}}else{password[j]='\0';break;}}password[j]='\0';}void DirF() /*Dir FileSystem*/{int i,j,count=0;char sfmode[25],sfpaddr[25],str[25];int ExistD(char *dirname); /*Whether DirName Exist,Exist-i,Not Exist-0*/clrscr();if (strcmp(strupr(ltrim(rtrim(dirname))),"")!=0){printf("\n\nC:\\%s>dir\n",dirname);printf("\n%14s%16s%14s%10s%18s\n","FileName","FileAddress","FileLength","Type","FileMode") ;j=ExistD(dirname);for(i=0;i<fcount[j];i++){if ((i%16==0)&&(i!=0)){printf("\nPress any key to continue..");getch();clrscr();printf("\n%14s%16s%14s%10s%18s\n","FileName","FileAddress","FileLength","Type","FileMode") ;}itoa(ufd[j]->ufdfile[i].fpaddr,str,10);strcpy(sfpaddr,"file");strcat(sfpaddr,str);if (ufd[j]->ufdfile[i].fmode==0) strcpy(sfmode,"Read Only");else if(ufd[j]->ufdfile[i].fmode==1) strcpy(sfmode,"Write Only");else if(ufd[j]->ufdfile[i].fmode==2)strcpy(sfmode,"Read And Write");else strcpy(sfmode,"Protect");printf("%14s%16s%14d%10s%18s\n",ufd[j]->ufdfile[i].fname,sfpaddr,ufd[j]->ufdfile[i].flength,"< FILE>",sfmode);}printf("\n %3d file(s)\n",fcount[j]);}{printf("\n\nC:\\>dir\n");printf("\n%14s%18s%8s\n","DirName","OwnFileCount","Type");for(i=0;i<ucount;i++){if ((i%16==0)&&(i!=0)){printf("\nPress any key to continue...");getch();clrscr();printf("\n%14s%18s%8s\n","DirName","OwnFileCount","Type");}printf("%14s%18d%8s\n",ufd[i]->ufdname,fcount[i],"<UFD>");count=count+fcount[i];}printf("\n %3d dir(s),%5d file(s)\n",ucount,count);}}int ExistD(char *dirname) /*Whether DirName Exist,Exist-i,Not Exist-0*/{int i;int exist=0;for(i=0;i<ucount;i++)if (strcmp(strupr(ufd[i]->ufdname),strupr(dirname))==0){exist=1;break;}if (exist) return(i);else return(-1);}void CdF() /*Exchange Dir*/{char dname[MAXNAME];char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/int ExistD(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/ printf("\nPlease input DirName (cd..-Previous dir; DirNAME-cd [DirNAME]):"); gets(dname);ltrim(rtrim(dname));if (ExistD(dname)>=0) strcpy(dirname,strupr(dname));else if(strcmp(strupr(dname),"CD..")==0) strcpy(ltrim(rtrim(dirname)),""); else printf("\nError.\'%s\' does not exist.\n",dname);}void CreateF() /*Create File*/{int fpaddrno,flag=1,i;char fname[MAXNAME],str[50],str1[50],strtext[255],a[25];char fmode[25];char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/int FindPANo(); /*find out physical address num*/int WriteF1(); /*write file*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/int ExistD(char *dirname);if (strcmp(strupr(dirname),strupr(username))!=0){printf("\nError. You must create file in your own dir.\n");wgetchar=1;}else{ printf("\nPlease input FileName:");gets(fname);ltrim(rtrim(fname));if (ExistF(fname)>=0){printf("\nError. Name \'%s\' has already existed.\n",fname);wgetchar=1;else{printf("Please input FileMode(0-Read Only, 1-Write Only, 2-Read and Write, 3-Protect):");gets(fmode);ltrim(rtrim(fmode));if((strcmp(fmode,"0")==0)||(strcmp(fmode,"1")==0)||(strcmp(fmode,"2")==0)||(strcmp(fmode, "3")==0)){fpaddrno=FindPANo();if (fpaddrno>=0){i=ExistD(username);strcpy(ufd[i]->ufdfile[fcount[i]].fname,fname);ufd[i]->ufdfile[fcount[i]].fpaddr=fpaddrno;ufd[i]->ufdfile[fcount[i]].fmode=atoi(fmode);ifopen[i][fcount[i]].ifopen=0;ifopen[i][fcount[i]].openmode=4;strcpy(str,"c:\\osfile\\file\\file");itoa(fpaddrno,str1,10);strcat(str,str1);fp_file=fopen(str,"wb");fclose(fp_file);fcount[i]++;while(flag){printf("Input text now(Y/N):");gets(a);ltrim(rtrim(a));ufd[i]->ufdfile[fcount[i]-1].flength=0;if(strcmp(strupr(a),"Y")==0){fp_file=fopen(str,"wb+");ufd[i]->ufdfile[fcount[i]-1].flength=WriteF1();flag=0;}else if(strcmp(strupr(a),"N")==0){flag=0;wgetchar=1;}}printf("\n\'%s\' has been created successfully!\n",fname);}else{printf("\nFail!No Disk Space. Please format your disk.\n");wgetchar=1;}}else {printf("\nError. FileMode\'s Range is 0-3\n");wgetchar=1;}}}}int ExistF(char *filename) /*Whether FileName Exist,Exist-i,Not Exist-0*/{int i,j;int exist=0;int ExistD(char *dirname);j=ExistD(dirname);for(i=0;i<fcount[j];i++)if (strcmp(strupr(ufd[j]->ufdfile[i].fname),strupr(filename))==0){exist=1;break;}if (exist) return(i);else return(-1);}int FindPANo() /*find out physical address num*/{int i;for(i=0;i<MAX;i++)if (fpaddrno[i]==0) {fpaddrno[i]=1;break;}if (i<MAX) return(i);else return(-1);}int WriteF1() /*write file*/{int length=0;char c;printf("Please input text(\'#\' stands for end):\n");while((c=getchar())!='#'){fprintf(fp_file,"%c",c);if (c!='\n') length++;}fprintf(fp_file,"\n");fclose(fp_file);return(length);}void DeleteF() /*Delete File*/{char fname[MAXNAME];char str[50],str1[50];int i,j,k,flag=1;char a[25]; /*whether delete*/char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/int ExistD(char *dirname);if (strcmp(strupr(dirname),strupr(username))!=0){printf("\nError. You can only delete file in your own dir.\n");wgetchar=1;}else{printf("\nPlease input FileName:");gets(fname);ltrim(rtrim(fname));i=ExistF(fname);if (i>=0){k=ExistD(username);if(ifopen[k][i].ifopen==1){printf("\nError. \'%s\' is in open status. Close it before delete.\n",fname);wgetchar=1;} else{ while(flag){printf("\'%s\' will be deleted. Are you sure(Y/N):",fname);gets(a);ltrim(rtrim(a));if(strcmp(strupr(a),"Y")==0){fpaddrno[ufd[k]->ufdfile[i].fpaddr]=0;itoa(ufd[k]->ufdfile[i].fpaddr,str,10);for(j=i;j<fcount[k]-1;j++){strcpy(ufd[k]->ufdfile[j].fname,ufd[k]->ufdfile[j+1].fname);ufd[k]->ufdfile[j].fpaddr=ufd[k]->ufdfile[j+1].fpaddr;ufd[k]->ufdfile[j].flength=ufd[k]->ufdfile[j+1].flength;ufd[k]->ufdfile[j].fmode=ufd[k]->ufdfile[j+1].fmode;ifopen[k][j]=ifopen[k][j+1];}fcount[k]--;strcpy(str1,"c:\\osfile\\file\\file");strcat(str1,str);remove(str1);flag=0;printf("\n\'%s\' has been deleted successfully.\n",fname);wgetchar=1;}else if(strcmp(strupr(a),"N")==0){printf("\nError. \'%s\' hasn\'t been deleted.\n",fname);wgetchar=1;flag=0;}}}}else{printf("\nError. \'%s\' does not exist.\n",fname);wgetchar=1;}}}void ModifyFM() /*Modify FileMode*/{char fname[MAXNAME],str[50];int i,j,k,flag;char fmode[25]; /*whether delete*/char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/void InputPW(char *password); /*input password,use '*' replace*/void SetPANo(int RorW); /*Set physical address num*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/int ExistD(char *dirname);if (strcmp(strupr(dirname),strupr(username))!=0) {printf("\nError.You can only modify filemode in yourself dir.\n");wgetchar=1;}else{ printf("\nPlease input FileName:");gets(fname);ltrim(rtrim(fname));i=ExistF(fname);if (i>=0){k=ExistD(username);if(ifopen[k][i].ifopen==1){printf("\nError.\'%s\' is in open status. Close it before modify.\n",fname);wgetchar=1;} else{if(ufd[k]->ufdfile[i].fmode==0) strcpy(str,"read only"); /*FileMode*/else if(ufd[k]->ufdfile[i].fmode==1) strcpy(str,"write only");else if(ufd[k]->ufdfile[i].fmode==2) strcpy(str,"read and write");else strcpy(str,"Protect");printf("\'%s\' filemode is %s.\n",fname,strupr(str));printf("Modify to(0-read only,1-write only,2-read and write,3-Protect):");gets(fmode);ltrim(rtrim(fmode));if(strcmp(fmode,"0")==0){ufd[k]->ufdfile[i].fmode=0;printf("\n\'%s\' has been modified to READ ONLY mode successfully.\n",fname);wgetchar=1;}else if(strcmp(fmode,"1")==0){ufd[k]->ufdfile[i].fmode=1;printf("\n\'%s\' has been modified to WRITE ONLY mode successfully.\n",fname);wgetchar=1;}else if(strcmp(fmode,"2")==0){ufd[k]->ufdfile[i].fmode=2;printf("\n\'%s\' has been modified to READ AND WRITE mode successfully.\n",fname);wgetchar=1;}else if(strcmp(fmode,"3")==0){ufd[k]->ufdfile[i].fmode=3;printf("\n\'%s\' has been modified to FORBID mode successfully.\n",fname);wgetchar=1;}else {printf("\nError.\'%s\' is not modified.\n",fname);wgetchar=1;}}}else{printf("\nError. \'%s\' dose not exist.\n",fname);wgetchar=1;}}}void OpenF() /*Open File*/{char fname[MAXNAME];char str[25],str1[25],fmode[25];int i,k;char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/int ExistD(char *dirname);if (strcmp(strupr(ltrim(rtrim(dirname))),"")==0){printf("\nError. Please change to ufd dir before open.\n");wgetchar=1;return;}printf("\nPlease input FileName:");gets(fname);ltrim(rtrim(fname));i=ExistF(fname);if (i>=0){k=ExistD(dirname);if(!ifopen[k][i].ifopen){if (ufd[k]->ufdfile[i].fmode==3){printf("\nError. The file\'s mode is FORBID. Can not open.\n");wgetchar=1;}else{printf("Please input FileOpenMode(0-Read Only,1-Write Only,2-Read and Write):");gets(fmode);ltrim(rtrim(fmode));if((strcmp(fmode,"0")==0)||(strcmp(fmode,"1")==0)||(strcmp(fmode,"2")==0)){if(fmode[0]=='0') /*open file with read only mode*/{strcpy(str,"read only");if((ufd[k]->ufdfile[i].fmode==0)||(ufd[k]->ufdfile[i].fmode==2)) ifopen[k][i].ifopen=1;}else if(fmode[0]=='1') /*open file with write only mode*/{strcpy(str,"write only");if((ufd[k]->ufdfile[i].fmode==1)||(ufd[k]->ufdfile[i].fmode==2)) ifopen[k][i].ifopen=1;}else if(fmode[0]=='2') /*open file with read and write mode*/{strcpy(str,"read and write");if(ufd[k]->ufdfile[i].fmode==2) ifopen[k][i].ifopen=1;}if(ufd[k]->ufdfile[i].fmode==0) strcpy(str1,"read only"); /*FileMode*/else if(ufd[k]->ufdfile[i].fmode==1) strcpy(str1,"write only");else if(ufd[k]->ufdfile[i].fmode==2) strcpy(str1,"read and write");if(ifopen[k][i].ifopen==1){ifopen[k][i].openmode=atoi(fmode);if (ifopen[k][i].openmode==0) strcpy(str,"read only");else if(ifopen[k][i].openmode==1) strcpy(str,"write only");else if(ifopen[k][i].openmode==2) strcpy(str,"read and write");printf("\n\'%s\' has been opened. OpenMode is %s,FileMode is %s\n",fname,strupr(str),strupr(str1));wgetchar=1;}else{printf("\nError. \'%s\' hasn\'t been opened. OpenMode Error. OpenMode is %s,butFileMode is %s\n",fname,strupr(str),strupr(str1));wgetchar=1;}}else {printf("\nError. FileOpenMode\'s Range is 0-2\n");wgetchar=1;}}}else {printf("\nError. \'%s\' is in open status.\n",fname);wgetchar=1;}}else{printf("\nError. \'%s\' does not exist.\n",fname);wgetchar=1;}}void CloseF() /*Close File*/{int i,k,n=0;char fname[MAXNAME];char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/int ExistD(char *dirname);if (strcmp(strupr(ltrim(rtrim(dirname))),"")==0){printf("\nError. Please convert to ufd dir before close.\n");wgetchar=1;return;}k=ExistD(dirname);printf("\nOpen File(s) In This Ufd:\n");/*display openned file*/for(i=0;i<fcount[k];i++){if (ifopen[k][i].ifopen==1) {printf("%15s",ufd[k]->ufdfile[i].fname);n++;}if((n%4==0)&&(n!=0)) printf("\n");}printf("\n%d files openned.\n",n);if (n==0) wgetchar=1;if(n!=0){printf("\nPlease input FileName:");gets(fname);ltrim(rtrim(fname));i=ExistF(fname);if(i>=0){if(ifopen[k][i].ifopen==1){ifopen[k][i].ifopen=0;ifopen[k][i].openmode=4;printf("\n\'%s\' has been closed successfully.\n",fname);wgetchar=1;}else {printf("\nError.\'%s\' is in closing status.\n",fname);wgetchar=1;}}else {printf("\nError. \'%s\' is not exist.\n",fname);wgetchar=1;}}}void ReadF() /*Read File*/{int i,k,n=0;char fname[MAXNAME];char str[255],str1[255],c;char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/int ExistD(char *dirname);if (strcmp(strupr(ltrim(rtrim(dirname))),"")==0) {printf("\nError.Please convert to ufd dir before read.\n");wgetchar=1;return;}printf("\nCaution:Open file first\n");printf("Opened File(s) List:\n");k=ExistD(dirname);for(i=0;i<fcount[k];i++){if (ifopen[k][i].ifopen==1)if ((ifopen[k][i].openmode==0) ||(ifopen[k][i].openmode==2)) {printf("%15s",ufd[k]->ufdfile[i].fname);n++;}if((n%4==0)&&(n!=0)) printf("\n");}printf("\n%d files openned.\n",n);if (n==0) wgetchar=1;if(n!=0){printf("\nPlease input FileName:");gets(fname);ltrim(rtrim(fname));i=ExistF(fname);if(i>=0){if(ifopen[k][i].ifopen==1){if((ifopen[k][i].openmode==0) ||(ifopen[k][i].openmode==2)){itoa(ufd[k]->ufdfile[i].fpaddr,str,10);strcpy(str1,"file");strcat(str1,str);strcpy(str,"c:\\osfile\\file\\");strcat(str,str1);fp_file=fopen(str,"rb");fseek(fp_file,0,0);printf("\nThe text is:\n\n");printf(" ");while(fscanf(fp_file,"%c",&c)!=EOF)if (c=='\n') printf("\n ");else printf("%c",c);printf("\n\n%d Length.\n",ufd[k]->ufdfile[i].flength);fclose(fp_file);wgetchar=1;}else{printf("\nError.\'%s\' has been opened with WRITE ONLY mode. It isn\'t read.\n",fname);wgetchar=1;}}else {printf("\nError.\'%s\' is in closing status. Please open it before read\n",fname);wgetchar=1;}}else {printf("\nError. \'%s\' does not exist.\n",fname);wgetchar=1;}}}void WriteF() /*Write File*/{int i,k,n=0;char fname[MAXNAME];char str[50],str1[50],a[50];char *rtrim(char *str); /*remove the trailing blanks.*/char *ltrim(char *str); /*remove the heading blanks.*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/int ExistD(char *dirname);int WriteF1(); /*write file*/if (strcmp(strupr(ltrim(rtrim(dirname))),"")==0) {printf("\nError. Please convert to ufd dir before write.\n");wgetchar=1;return;}k=ExistD(dirname);printf("\nOpen File(s) with write only mode or read and write mode:\n");/*display openned files with writable mode*/for(i=0;i<fcount[k];i++){if (ifopen[k][i].ifopen==1)if ((ifopen[k][i].openmode==1) ||(ifopen[k][i].openmode==2)) {printf("%15s",ufd[k]->ufdfile[i].fname);n++;}if((n%4==0)&&(n!=0)) printf("\n");}printf("\n%d files open.\n",n);if (n==0) wgetchar=1;if(n!=0){printf("\nPlease input FileName:");gets(fname);ltrim(rtrim(fname));i=ExistF(fname);if(i>=0){if(ifopen[k][i].ifopen==1){if((ifopen[k][i].openmode==1) ||(ifopen[k][i].openmode==2)){itoa(ufd[k]->ufdfile[i].fpaddr,str,10);strcpy(str1,"file");strcat(str1,str);strcpy(str,"c:\\osfile\\file\\");strcat(str,str1);if (ufd[k]->ufdfile[i].flength!=0){printf("\n\'%s\' has text. Overwrite or Append(O-overwrite,A-Append,else-not write):",fname);gets(a);ltrim(rtrim(a));if (fp_file!=NULL) fclose(fp_file);if (strcmp(strupr(a),"O")==0){printf("\nOverwrite\n");fp_file=fopen(str,"wb");ufd[k]->ufdfile[i].flength=0;ufd[k]->ufdfile[i].flength=WriteF1();}else if(strcmp(strupr(a),"A")==0){printf("\nAppend\n");fp_file=fopen(str,"ab");ufd[k]->ufdfile[i].flength=ufd[k]->ufdfile[i].flength+WriteF1();}else{printf("\nError.\'%s\' has not been written.\n",fname);fclose(fp_file);wgetchar=1;}}else{fp_file=fopen(str,"wb");ufd[k]->ufdfile[i].flength=WriteF1();} }else{printf("\nError. \'%s\' has been opened with read only mode.It isn\'t writed.\n",fname);wgetchar=1;}}else{printf("\nError. \'%s\' is in closing status. Please open it before write\n",fname);wgetchar=1;}}else{printf("\nError. \'%s\' does not exist.\n",fname);wgetchar=1;}}}void QuitF() /*Quit FileSystem*/{int i,j;char str[50];void SetPANo(int RorW); /*Set physical address num,0-read,1-write*/。