homework1:
What is Operating System?
An operating system is a program that manages the computer hardware.It also provides a basis for application programs and acts as an intermediary between the computer user and the computer hardware.
Some operating systems in details:
1.Linux :
Linux is a set of free-to-use and free-to-spread Unix-like operating system. It is a multi-user, multi-task, multi-threaded and multi-CPU operating system based on POSIX and Unix. With the development of the Internet, Linux has been supported by software enthusiasts, organizations and companies from all over the world. In addition to maintaining a strong momentum of development in server operating system, it has made considerable progress in personal computers and embedded systems. Users can not only intuitively obtain the implementation mechanism of the operating system, but also can modify and improve the operating system according to their own needs, so as to maximize its adaptation to the needs of users.
Linux is not only stable in system performance, but also open source software. Its core firewall components have high performance and simple configuration, which ensures the security of the system. In many enterprise networks, in order to pursue speed and security, Linux operating system is not only used as a server by network operators. Linux can be used as a server, but also as a network firewall, which is a highlight of Linux.
Compared with other operating systems, Linux has the characteristics of open source, no copyright and more users in the technical community. Open source enables users to tailor freely, with high flexibility, powerful functions and low cost. Especially the embedded network protocol stack in the system can realize the function of router through proper configuration. These characteristics make Linux an ideal platform for developing routing switching devices.
2.Mac OS:
Mac OS is an operating system running on Apple Macintosh computers. Mac OS is the first graphical user interface operating system to succeed in business. The latest version of the current system is macOS 10.15 beta 4, and there are Mac systems (Hackintosh) running on PCs on the Internet.
Mac system is a graphical operating system based on Unix kernel; in general, it can not be installed on ordinary PC. Developed by Apple itself. The operating system of the Mac has reached OS 10, codenamed Mac OS X (Roman numeric notation for X 10), which is the biggest change in the 15 years since the birth of the Mac computer. The new system is very reliable; many of its features and services embody Apple’s philosophy.
In addition, the rampant computer viruses are almost all targeted at Windows. Because the architecture of MAC is different from Windows, it is seldom attacked by viruses. MacOS operating system interface is very unique, highlighting the image of icons and human-computer dialogue. Apple not only develops its own system, but also involves hardware development.
3.windows:
Microsoft Windows Operating System is a set of operating system developed by Microsoft Corporation in the United States. It came into being in 1985.
Its characteristics:
-
Windows operating system has excellent maneuverability.
-
There are many applications supported by Windows operating system.
-
Windows operating system supports hardware well.
homework2
describe the life circle of process and why each process must have one PCB.
Q1
We all know that a process has five states: new, running, waiting, ready, terminated. The lifecircle of the process starts when it is created. When it is allowed, it will be ready. The process in the ready state is allocated by the scheduling algorithm to run. When the running process receives the exit instruction, it enters the termination state, and the process ends. Of course, the running process will also receive I/O operation or event waiting requirements, thus entering the waiting state. When I/O operations and events are completed, the process is ready for the next instruction. Running processes are also ready to receive interrupt instructions.
Q2
Each process will occupy CPU, so in order to control each process and realize CPU switching between processes, each process is controlled by a PCB.
homework3
design your example and give computation results of several cpu schedulers
homework4
think about your possible case about process synchronization, and give out a solution for the problem.
My case of process synchronization:
Case:
A small bridge (up to two people can bear) spans both sides of the north and south, allowing only one person to cross the bridge at any time in the same direction; the southern section and the northern section of the bridge are relatively narrow and can only be passed by one person, with a spacious central section allowing two people to pass or rest.
Solution:
Usage:
Load
South
North
Pseudo code:
int countSN=0;
int countNS=0;
semaphore mutexSN=1;
semaphore mutexNS=1;
semaphore bridge=1;
NorthtoSouth(){
P(mutexNS);
If(countNS==0)
P(bridge);
countNS++;
V(mutexNS);
//across the bridge
P(mutexNS);
countNS–;
If(countNS==0)
V(bridge);
V(mutexNS);
}
SouthtoNorth(){
P(mutexSN);
If(countSN==0)
P(bridge);
countSN++;
V(mutexSN);
//across the bridge
P(mutexSN);
countSN–;
If(countSN=0)
V(bridge);
V(mutexSN);
}
homework5
describe your understadings about Banker’s Algorithm, and give your own demo example.
My understanding of Banker’s Algorithm:
The banker algorithm determines how to allocate resources by dynamically detecting the resource allocation in the system and the demand for resources by the process. When the system is in a safe state, the resources can be allocated to the applicant, thereby avoiding system deadlock.
My own demo:
Set : A has 25 instances , B has 12 instances, C has 11 instances
Max Allocation
A,B,C A,B,C
P0 4,2,4 4,0,0
P1 3,6,2 2,1,1
P2 7,2,1 3,1,1
P3 5,5,5 3,3,3
P4 4,2,1 2,2,1
At present the rest instances of A 、B、C are 11,5,5
The amount of resources required for each process is:
P0 P1 P2 P3 P4
A,B,C 0,2,4 1,5,1 4,1,0 2,2,2 2,0,0
Write a Security sequence:
P0->P1->P2->P3->P4
homework6
similar to figure 8.10 , draw your own demo illustration figure
homework7
When page fault happens in virtual memory management, what is the steps of OS to handle this situation?
Find a free page. Or write another active page to disk (if it changes after the last write), and log off the record in MMU
Read data into the selected page
Register this page with MMU
homework8
In Virtual memory management, demostrate one of the page replacement algorithms.
homework9
describe advantages and disadvantages of each allocation method for disk space
1.contiguous allocation
advantages:
1):It’s convenient to access.
2):The number of disk seeks required is minimal.
3):The seek time is also minimal.
4):It supports sequential access and direct access.
disadvantages:
1):It should fine space for a new file.
2):dynamic storage-allocation
3):external fragmentation exists.
2.linked allocation
advantages:
1):Improve disk space utilization without external fragmentation.
2):Facilitate the insertion and deletion of files.
3):Conducive to the dynamic expansion of files.
disadvantages:
1):Can only be effectively used for sequential access to files.
2):the pointer needs spaces.
3):waste more disk spaces(more disk fragmentation).
4):reliability.If pointer is lost or damaged,bad things will happen.
3.indexed allocation
advantages:
1):no external fragmentation.
2):satisfies the requirements of dynamic file growth,insertion and deletion.
3):can make full use of external storage space.
disadvantages:
1):more seek times and seek spaces.
2):Index table itself brings system overhead,such as : internal and external storage
spaces.access time.
操作系统章节复习:
死锁章节:
每个请求都应用检测算法会引起非常大的计算开销
死锁预防至少要保证不满足死锁产生的4个必要条件之中的一个条件
决定一个请求是否被满足或是被延迟,系统必须先思考资源实时能否获取
reusable resource意味着这个资源可以被一个进程使用,并且不会消失
占有并等待的条件是 一个进程必须占有至少一个资源,并等待另一资源,而该资源为其他进程所占有
矩阵need的内容定义成matrix allocation
互斥状态:至少有一个资源处于非共享模式,即一次只有一个进程使用
不确定
如果经常发生死锁,就应该经常调用 检测算法
死锁发生需要四个条件 互斥、占有并等待、非抢占、循环等待
资源利用率低,每个进程再执行前申请获得所有资源
银行家算法缺点三个都是
非抢占部分
有环则不安全
资源的请求和释放是systen calls