Skip to content

Instantly share code, notes, and snippets.

View SomeBottle's full-sized avatar
😇
Drowning in the ocean of knowledge.

SomeBottle SomeBottle

😇
Drowning in the ocean of knowledge.
View GitHub Profile
@SomeBottle
SomeBottle / MemoryAllocation-WorstFit.c
Last active May 11, 2022 15:07
动态分区存储管理-内存分配-最坏适应WorstFit算法
/* 动态分区存储管理
* 实验要求
* 编写程序模拟实现内存的动态分区法存储管理。
* 内存空闲区使用空闲分区链管理,采用最坏适应算法从空闲分区链中寻找空闲区进行分配,
* 内存回收时假定不做与相邻空闲区的合并。
* 假定系统的内存共640K,初始状态为操作系统本身占用64K。
* 在t1时间之后,有作业A、B、C、D分别请求8K、16K、64K、124K的内存空间;
* 在t2时间之后,作业C完成;
* 在t3时间之后,作业E请求50K的内存空间;
* 在t4时间之后,作业D完成。
@SomeBottle
SomeBottle / maxCommonDiv.c
Created April 27, 2022 05:58
欧几里得算法求最大公约数
#include <stdio.h>
long int CommonDiv(long int num1, long int num2) { // 寻找两数最大公约数
long int dividend; // 被除数
long int divisor; // 除数
long int remainder; // 余数
if (num1 > num2) {
dividend = num1;
divisor = num2;
} else {
@SomeBottle
SomeBottle / Diagrams.md
Last active April 15, 2022 11:29
操作系统实验:作业调度(FCFS,SJF,HRRN算法,C语言实现)

FCFS

FCFS

SJF or HRRN

SJFandHRRN

@SomeBottle
SomeBottle / komi.gif
Last active April 27, 2022 03:37
(⊙. ⊙)
komi.gif
@SomeBottle
SomeBottle / ProcessorScheduling-PSA-preemptive-visual.js
Last active April 4, 2022 06:48
Processor Scheduling - Preemptive Priority Scheduling (PSA Preemptive) Algorithm 抢占式优先级调度算法
'use strict';
// Preemptive Priority Scheduling (PSA Preemptive) Algorithm 抢占式优先级调度算法
let smallerValHigherPriority = true, // 小值优先级高(为false就是大值优先级高)
processes = [
['A', 10, 0, 5],
['B', 1, 1, 1],
['C', 5, 2, 3],
['D', 1, 3, 2],
['E', 2, 4, 4]
], // [进程名,运行时间,到达输入井时间(从0ms开始),指定的优先级]
@SomeBottle
SomeBottle / ProcessorScheduling-SRTF-visual.js
Last active April 4, 2022 06:48
Processor Scheduling - Shortest Remaining Time First (SRTF) 最短剩余时间优先调度算法(抢占式)
'use strict';
// Shortest Remaining Time First (SRTF) Algorithm 最短剩余时间优先调度算法(抢占式)
let processes = [
['P1', 10, 0],
['P2', 1, 1],
['P3', 5, 2],
['P4', 1, 3],
['P5', 2, 4]
], // [进程名,运行时间,到达输入井时间(从0ms开始)]
readyQueue = [], // 就绪队列
@SomeBottle
SomeBottle / ProcessorScheduling-HRRN-visual.js
Last active April 4, 2022 06:48
Processor Scheduling - Highest Response Ratio Next (高响应比优先调度算法)
'use strict';
// Highest Response Ratio Next (HRRN) 高响应比优先调度算法(非抢占式)
let processes = [
['P2', 30, 10],
['P1', 20, 0],
['P3', 25, 20],
['P4', 10, 30],
['P5', 15, 40]
], // [进程名,运行时间,到达输入井时间(从0ms开始)]
readyQueue = [], // 就绪队列
@SomeBottle
SomeBottle / ProcessorScheduling-FCFS-visual.js
Last active April 4, 2022 06:49
Processor Scheduling-First Come First Serve(先来先服务调度算法)
'use strict';
// First Come First Serve(FCFS) 先来先服务调度算法(非抢占式)
let processes = [
['P2', 30, 10],
['P1', 20, 0],
['P3', 25, 20],
['P4', 10, 30],
['P5', 15, 40]
], // [进程名,运行时间,到达输入井时间(从0ms开始)]
readyQueue = [], // 就绪队列
@SomeBottle
SomeBottle / ProcessScheduling-RR-visual.js
Last active April 4, 2022 06:28
Process Scheduling - Robin Round with Time slices(时间片轮转调度算法)
'use strict';
// Robin Round(Using limited time slice) Algorithm 时间片轮转调度算法(抢占式)
let processes = [
['P1', 10, 0],
['P2', 1, 1],
['P3', 5, 2],
['P4', 1, 3],
['P5', 2, 4]
], // [进程名,运行时间,到达输入井时间(从0ms开始)]
readyQueue = [], // 就绪队列
@SomeBottle
SomeBottle / ProcessorScheduling-PSA-non-preemptive-visual.js
Last active April 4, 2022 06:49
Processor Scheduling - Priority Scheduling Algo (non-preemptive)(优先级调度算法(非抢占式))
'use strict';
// PSA,优先级调度算法(非抢占式)
let arr = [['A', 10, 3], ['B', 6, 5], ['C', 2, 2], ['D', 4, 1], ['E', 8, 4]], // [进程名,运行时间,优先级(数字越大越优先)]
overall = 0;
arr.sort((x, y) => y[2] - x[2]);
for (let i = 0, len = arr.length; i < len; i++) {
let item = arr[i],
spend = item[1],
sumBefore = 0;
for (let j = 0; j < i; j++) {