Operating system simulation experiment

To get straight to the point, this article shares with you a code developed by me, which mainly realizes several small experiments of online simulation operating system. It can be said to be an online simulation platform (project files can be downloaded by myself when they are transmitted to resources, and I can also get private stamps)

Project documents https://download.csdn.net/download/siper12138/19785232?spm=1001.2014.3001.5503

The platform has certain limitations and can only simulate the following four experiments

2 processor scheduling (20 points)

1.1 experimental purpose
Be familiar with various algorithms of single processor scheduling, and deepen the understanding of processor scheduling mechanism. Practice the programming skills of simulation algorithm and the ability to analyze test data.
1.2 experimental description
Give a process scheduling instance randomly, such as:
Process arrival time service time
A 0 3
B 2 6
C 4 4
D 6 5
E 8 2
Simulate process scheduling, and give the completion time, turnaround time and weighted turnaround time of each process according to the algorithm of first come first service FCFS, rotation RR (q=1), shortest process priority SJF (non preemptive mode) and highest response ratio priority HRN (non preemptive mode).

3. Computer operation of storage management (20 points)

3.1 experimental purpose
Further understand the related contents of memory management. Understand the main tasks of memory management. Understand the main implementation methods of memory management tasks. Deepen the understanding of the principle of main algorithms such as memory allocation and recycling through programming.
3.2 experimental description
1. In this experiment, the variable partition method is used to complete the management of storage space (that is, the allocation and recycling of storage space).
2. The data structure designed to record the usage of main memory: partitioned table and free partitioned table.
3. Design a main memory allocation algorithm on the designed data structure. The basic functions and operations required to be realized include: finding free partitions, modifying free partition tables, and modifying partitioned tables.
4. A main memory recovery algorithm is designed on the designed data structure. Among them, if the recovered partitions have upper adjacent free partitions and / or lower adjacent free partitions, they are required to be merged into one free partition and registered in a table entry of the free partition table.
5. Every time the system allocates or reclaims memory, it shall give a memory image map or allocated tables and unallocated tables to observe the changes of memory.

4. Disk arm shifting scheduling algorithm experiment (20 points)

4.1 experimental purpose
Deepen the understanding of operating system equipment management technology and experience the importance of disk arm shift scheduling algorithm; Master several important disk arm moving scheduling algorithms, practice the programming skills of simulation algorithms, and exercise the ability to study and analyze test data.
4.2 experimental description

  1. In the example experimental program, two disk boom scheduling algorithms are simulated: SSTF algorithm and SCAN algorithm
  2. The two algorithms can be given any sequence of different disk request sequences to display the process of responding to disk requests.
  3. It can count and report the order of responding to requests and the total amount of moving arms under different algorithms.

5 document management (20 points)

5.1 experimental purpose
Through the creation and deletion of simulation files, deepen the understanding of the file management function of the operating system, practice the programming skills of simulation algorithms, and exercise the ability to study and analyze test data.
5.2 experimental description
Give a disk block sequence: 1, 2, 3,..., 500. In the initial state, all blocks are empty, and the size of each block is 2k. Choose one of three algorithms: free table, free disk chain and bit diagram to manage free blocks. For block based index allocation, perform the following steps:
(1) 50 2k-10k files are randomly generated, and the file name is 1 txt,2.txt,……,50.txt, which is stored in the analog disk according to the above algorithm.
(2) Delete odd numbers Txt (1.txt, 3.txt,..., 49.txt) files
(3) Create 5 new files (A.txt, B.txt, C.txt, D.txt and E.txt) with sizes of 7k, 5k, 2k, 9k and 3.5k, and store them in the analog disk according to the same algorithm as (1).
(4) The disk block storage status of files A.txt, B.txt, C.txt, D.txt and E.txt and the status of all free blocks are given.

preparation

1. Install external library files

The following library files need to be installed:

Click==7.0
Flask==1.0.2
itsdangerous==1.1.0
Jinja2==2.10
MarkupSafe==1.1.0
passlib==1.7.1
PyMySQL==0.9.3
Werkzeug==0.14.1
WTForms==2.2.1

2. Establish database
Database name: osmode
Database establishment:

/*
 Navicat Premium Data Transfer

 Source Server         : homework1
 Source Server Type    : MySQL
 Source Server Version : 80017
 Source Host           : localhost:3306
 Source Schema         : osmode

 Target Server Type    : MySQL
 Target Server Version : 80017
 File Encoding         : 65001

 Date: 15/06/2021 09:10:17
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for ccgl_list
-- ----------------------------
DROP TABLE IF EXISTS `ccgl_list`;
CREATE TABLE `ccgl_list`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `tp` int(10) NULL DEFAULT NULL,
  `state` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for ccgl_wfplist
-- ----------------------------
DROP TABLE IF EXISTS `ccgl_wfplist`;
CREATE TABLE `ccgl_wfplist`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `s` int(10) NULL DEFAULT NULL,
  `r` int(10) NULL DEFAULT NULL,
  `e` int(10) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 270 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for ccgl_yfplist
-- ----------------------------
DROP TABLE IF EXISTS `ccgl_yfplist`;
CREATE TABLE `ccgl_yfplist`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `j_r` int(10) NULL DEFAULT NULL,
  `s` int(10) NULL DEFAULT NULL,
  `r` int(10) NULL DEFAULT NULL,
  `e` int(10) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 56 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cljdd_fcfs_result
-- ----------------------------
DROP TABLE IF EXISTS `cljdd_fcfs_result`;
CREATE TABLE `cljdd_fcfs_result`  (
  `jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `st` int(10) NOT NULL,
  `et` int(10) NOT NULL,
  `zt` int(10) NOT NULL,
  `dqzt` float NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ctime` datetime NOT NULL,
  `dt` int(10) NOT NULL,
  `ft` int(10) NOT NULL,
  PRIMARY KEY (`jname`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cljdd_hrn_result
-- ----------------------------
DROP TABLE IF EXISTS `cljdd_hrn_result`;
CREATE TABLE `cljdd_hrn_result`  (
  `jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `st` int(10) NOT NULL,
  `et` int(10) NOT NULL,
  `zt` int(10) NOT NULL,
  `dqzt` float NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ctime` datetime NOT NULL,
  `dt` int(10) NOT NULL,
  `ft` int(10) NOT NULL,
  PRIMARY KEY (`jname`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cljdd_j
-- ----------------------------
DROP TABLE IF EXISTS `cljdd_j`;
CREATE TABLE `cljdd_j`  (
  `id` int(8) NOT NULL AUTO_INCREMENT,
  `Jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `dt` int(8) NOT NULL,
  `ft` int(8) NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `c_time` datetime NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 54 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cljdd_rr_result
-- ----------------------------
DROP TABLE IF EXISTS `cljdd_rr_result`;
CREATE TABLE `cljdd_rr_result`  (
  `jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `st` int(10) NOT NULL,
  `et` int(10) NOT NULL,
  `zt` int(10) NOT NULL,
  `dqzt` float NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ctime` datetime NOT NULL,
  `dt` int(10) NOT NULL,
  `ft` int(10) NOT NULL,
  PRIMARY KEY (`jname`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cljdd_rr_state
-- ----------------------------
DROP TABLE IF EXISTS `cljdd_rr_state`;
CREATE TABLE `cljdd_rr_state`  (
  `t` int(10) NOT NULL,
  `jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `state` int(10) NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ctime` datetime NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2449 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cljdd_sjf_result
-- ----------------------------
DROP TABLE IF EXISTS `cljdd_sjf_result`;
CREATE TABLE `cljdd_sjf_result`  (
  `jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `st` int(10) NOT NULL,
  `et` int(10) NOT NULL,
  `zt` int(10) NOT NULL,
  `dqzt` float NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ctime` datetime NOT NULL,
  `dt` int(10) NOT NULL,
  `ft` int(10) NOT NULL,
  PRIMARY KEY (`jname`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cpyb_c
-- ----------------------------
DROP TABLE IF EXISTS `cpyb_c`;
CREATE TABLE `cpyb_c`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `cidao` int(10) NOT NULL,
  `ctime` datetime NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 30 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cpyb_scan_result
-- ----------------------------
DROP TABLE IF EXISTS `cpyb_scan_result`;
CREATE TABLE `cpyb_scan_result`  (
  `cidao` int(10) NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ctime` datetime NOT NULL,
  `stemp` int(10) NOT NULL,
  `t` int(10) NOT NULL,
  PRIMARY KEY (`t`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cpyb_sstf_result
-- ----------------------------
DROP TABLE IF EXISTS `cpyb_sstf_result`;
CREATE TABLE `cpyb_sstf_result`  (
  `cidao` int(10) NOT NULL,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ctime` datetime NOT NULL,
  `stemp` int(10) NOT NULL,
  `t` int(10) NOT NULL,
  PRIMARY KEY (`t`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`  (
  `id` int(8) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wjgl_list
-- ----------------------------
DROP TABLE IF EXISTS `wjgl_list`;
CREATE TABLE `wjgl_list`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `tp` int(10) NULL DEFAULT NULL,
  `state` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 651 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wjgl_wfplist
-- ----------------------------
DROP TABLE IF EXISTS `wjgl_wfplist`;
CREATE TABLE `wjgl_wfplist`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `s` int(10) NULL DEFAULT NULL,
  `r` int(10) NULL DEFAULT NULL,
  `e` int(10) NULL DEFAULT NULL,
  `sk` int(10) NULL DEFAULT NULL,
  `ek` int(10) NULL DEFAULT NULL,
  `rk` int(10) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 269 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wjgl_yfplist
-- ----------------------------
DROP TABLE IF EXISTS `wjgl_yfplist`;
CREATE TABLE `wjgl_yfplist`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `usename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `jname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `j_r` int(10) NULL DEFAULT NULL,
  `s` int(10) NULL DEFAULT NULL,
  `r` int(10) NULL DEFAULT NULL,
  `e` int(10) NULL DEFAULT NULL,
  `sk` int(10) NULL DEFAULT NULL,
  `ek` int(10) NULL DEFAULT NULL,
  `rk` int(10) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 56 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

Operating instructions


1. User registration

2. User login

3. After logging in, you can enter the home page and select the experiment to be simulated

(1) Processor scheduling





(2) Storage management

Initial state of main memory main memory is empty (the minimum available unit is 8bt, and the total number of available units is 1024bt)

Add three process ABC and allocate space for them. According to the fist ft algorithm, allocate space for ABC in turn to obtain the partition table as shown in the figure.

Reclaim the space of a process B, as shown in the figure, the main memory space occupied by B is reclaimed

Add a process D and allocate space for it

According to the main memory space required by D, the first free partition just meets the requirements.

Add a process E and allocate space for it

According to the main memory space required by E, the first free partition cannot meet the requirements. Find the first free partition that can be put into the secondary process and allocate space for it.

(3) Storage management



(4) Document management

1. The initial state of the disk is empty


2. 50 2k-10k files are randomly generated, and the file name is 1 txt,2.txt,……,50.txt, which is stored in the analog disk according to the above algorithm.


3. Delete odd numbers Txt (1.txt, 3.txt,..., 49.txt) files


4. Create five new files (A.txt, B.txt, C.txt, D.txt, E.txt) with sizes of 7k, 5k, 2k, 9k and 3.5k, and store them in the analog disk according to the same algorithm as (1).


5. Give the disk block storage status of files A.txt, B.txt, C.txt, D.txt and E.txt and the status of all free blocks.

Keywords: Python Algorithm Operating System Flask

Added by bpopp on Mon, 24 Jan 2022 19:51:39 +0200