基於mykernel 2.0編寫一個操作系統內核

来源:https://www.cnblogs.com/ustca/archive/2020/05/13/12874785.html
-Advertisement-
Play Games

資源下載: "https://github.com/mengning/mykernel" 實驗內容: 1、配置實驗環境,完成Linux內核編譯。 2、對系統源碼進行修改,基於mykernel 2.0實現一個簡單的操作系統內核。 3、簡要分析操作系統內核核心功能及運行工作機制。 實驗環境: VMWar ...


資源下載:https://github.com/mengning/mykernel

實驗內容:

1、配置實驗環境,完成Linux內核編譯。

2、對系統源碼進行修改,基於mykernel 2.0實現一個簡單的操作系統內核。

3、簡要分析操作系統內核核心功能及運行工作機制。

實驗環境:

VMWare虛擬機下的Ubuntu18.04.4,實驗採用的內核版本為linux-5.4.34。


1 內核編譯

1.1 準備工作

1.1.1 修改鏡像源地址

為了節省資源下載時間,使用國內鏡像源。

cd /etc/apt/
sudo cp sources.list sources.list.bk
sudo gedit sources.list
deb http://mirrors.aliyun.com/ubuntu bionic main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-updates main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-backports main multiverse restricted universe

將sources.list修改保存後,更新apt源。

sudo apt-get update

1.1.2 添加hosts映射

新增GitHub資源功能變數名稱與對應IP的映射。

sudo vi /etc/hosts
151.101.76.133 raw.githubusercontent.com

1.1.3 安裝axel

多線程下載工具,用於下載Linux內核。

sudo apt install axel

1.2 下載內核補丁

wget https://raw.github.com/mengning/mykernel/master/mykernel-2.0_for_linux-5.4.34.patch

補丁文件如下,根據diff對比,主要做了以下改動:

  • 在時鐘中斷時調用自定義的my_timer_handler函數,列印輸出>>>>>>>my_timer_handler here<<<<<<<<
  • 在start_kernel.h與timer.h中分別聲明my_start_kernel與my_timer_handler函數
  • 在main.c中調用my_start_kernel函數
  • 在Makefile中新增mykernel的編譯路徑
  • 創建mykernel的Makefile文件
  • 編寫myinterrupt.c與mymain.c文件,mymain.c中模擬系統運行,每100000次迴圈輸出一次
diff -Naur linux-5.4.34/arch/x86/kernel/time.c linux-5.4.34-mykernel/arch/x86/kernel/time.c
--- linux-5.4.34/arch/x86/kernel/time.c	2020-04-21 15:05:05.000000000 +0800
+++ linux-5.4.34-mykernel/arch/x86/kernel/time.c	2020-04-25 21:58:16.436717811 +0800
@@ -16,6 +16,7 @@
 #include <linux/irq.h>
 #include <linux/i8253.h>
 #include <linux/time.h>
+#include <linux/timer.h>
 #include <linux/export.h>
 
 #include <asm/vsyscall.h>
@@ -59,6 +60,7 @@
 static irqreturn_t timer_interrupt(int irq, void *dev_id)
 {
 	global_clock_event->event_handler(global_clock_event);
+    	my_timer_handler();
 	return IRQ_HANDLED;
 }
 
diff -Naur linux-5.4.34/include/linux/start_kernel.h linux-5.4.34-mykernel/include/linux/start_kernel.h
--- linux-5.4.34/include/linux/start_kernel.h	2020-04-21 15:05:05.000000000 +0800
+++ linux-5.4.34-mykernel/include/linux/start_kernel.h	2020-04-25 22:00:17.304717811 +0800
@@ -9,6 +9,7 @@
    up something else. */
 
 extern asmlinkage void __init start_kernel(void);
+extern void __init my_start_kernel(void);
 extern void __init arch_call_rest_init(void);
 extern void __ref rest_init(void);
 
diff -Naur linux-5.4.34/include/linux/timer.h linux-5.4.34-mykernel/include/linux/timer.h
--- linux-5.4.34/include/linux/timer.h	2020-04-21 15:05:05.000000000 +0800
+++ linux-5.4.34-mykernel/include/linux/timer.h	2020-04-25 21:56:45.064717811 +0800
@@ -193,6 +193,8 @@
 
 extern void init_timers(void);
 extern void run_local_timers(void);
+extern void my_timer_handler(void);
+
 struct hrtimer;
 extern enum hrtimer_restart it_real_fn(struct hrtimer *);
 
diff -Naur linux-5.4.34/init/main.c linux-5.4.34-mykernel/init/main.c
--- linux-5.4.34/init/main.c	2020-04-21 15:05:05.000000000 +0800
+++ linux-5.4.34-mykernel/init/main.c	2020-04-25 22:01:13.476717811 +0800
@@ -781,6 +781,7 @@
 	arch_post_acpi_subsys_init();
 	sfi_init_late();
 
+    	my_start_kernel();
 	/* Do the rest non-__init'ed, we're now alive */
 	arch_call_rest_init();
 }
diff -Naur linux-5.4.34/Makefile linux-5.4.34-mykernel/Makefile
--- linux-5.4.34/Makefile	2020-04-21 15:05:05.000000000 +0800
+++ linux-5.4.34-mykernel/Makefile	2020-04-25 22:02:47.144717811 +0800
@@ -1012,7 +1012,7 @@
 export MODORDER := $(extmod-prefix)modules.order
 
 ifeq ($(KBUILD_EXTMOD),)
-core-y		+= kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
+core-y		+= kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ mykernel/
 
 vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
diff -Naur linux-5.4.34/mykernel/Makefile linux-5.4.34-mykernel/mykernel/Makefile
--- linux-5.4.34/mykernel/Makefile	1970-01-01 08:00:00.000000000 +0800
+++ linux-5.4.34-mykernel/mykernel/Makefile	2020-04-25 17:14:13.537908421 +0800
@@ -0,0 +1,6 @@
+#
+# Makefile for the linux mykernel.
+#
+
+obj-y     = mymain.o myinterrupt.o
+
diff -Naur linux-5.4.34/mykernel/myinterrupt.c linux-5.4.34-mykernel/mykernel/myinterrupt.c
--- linux-5.4.34/mykernel/myinterrupt.c	1970-01-01 08:00:00.000000000 +0800
+++ linux-5.4.34-mykernel/mykernel/myinterrupt.c	2020-04-25 19:09:50.612555999 +0800
@@ -0,0 +1,44 @@
+/*
+ *  linux/mykernel/myinterrupt.c
+ *
+ *  Kernel internal my_timer_handler
+ *
+ *  Copyright (C) 2013  Mengning
+ *
+ */
+#include <linux/kernel_stat.h>
+#include <linux/export.h>
+#include <linux/interrupt.h>
+#include <linux/percpu.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/pid_namespace.h>
+#include <linux/notifier.h>
+#include <linux/thread_info.h>
+#include <linux/time.h>
+#include <linux/jiffies.h>
+#include <linux/posix-timers.h>
+#include <linux/cpu.h>
+#include <linux/syscalls.h>
+#include <linux/delay.h>
+#include <linux/tick.h>
+#include <linux/kallsyms.h>
+#include <linux/irq_work.h>
+#include <linux/sched.h>
+#include <linux/sched/sysctl.h>
+#include <linux/slab.h>
+
+#include <asm/uaccess.h>
+#include <asm/unistd.h>
+#include <asm/div64.h>
+#include <asm/timex.h>
+#include <asm/io.h>
+
+/*
+ * Called by timer interrupt.
+ */
+void my_timer_handler(void)
+{
+	pr_notice("\n>>>>>>>>>>>>>>>>>my_timer_handler here<<<<<<<<<<<<<<<<<<\n\n");
+}
diff -Naur linux-5.4.34/mykernel/mymain.c linux-5.4.34-mykernel/mykernel/mymain.c
--- linux-5.4.34/mykernel/mymain.c	1970-01-01 08:00:00.000000000 +0800
+++ linux-5.4.34-mykernel/mykernel/mymain.c	2020-04-25 19:10:27.635058000 +0800
@@ -0,0 +1,91 @@
+/*
+ *  linux/mykernel/mymain.c
+ *
+ *  Kernel internal my_start_kernel
+ *
+ *  Copyright (C) 2013  Mengning
+ *
+ */
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/kernel.h>
+#include <linux/syscalls.h>
+#include <linux/stackprotector.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/initrd.h>
+#include <linux/acpi.h>
+#include <linux/tty.h>
+#include <linux/percpu.h>
+#include <linux/kmod.h>
+#include <linux/vmalloc.h>
+#include <linux/kernel_stat.h>
+#include <linux/start_kernel.h>
+#include <linux/security.h>
+#include <linux/smp.h>
+#include <linux/profile.h>
+#include <linux/rcupdate.h>
+#include <linux/moduleparam.h>
+#include <linux/kallsyms.h>
+#include <linux/writeback.h>
+#include <linux/cpu.h>
+#include <linux/cpuset.h>
+#include <linux/cgroup.h>
+#include <linux/efi.h>
+#include <linux/tick.h>
+#include <linux/interrupt.h>
+#include <linux/taskstats_kern.h>
+#include <linux/delayacct.h>
+#include <linux/unistd.h>
+#include <linux/rmap.h>
+#include <linux/mempolicy.h>
+#include <linux/key.h>
+#include <linux/buffer_head.h>
+#include <linux/debug_locks.h>
+#include <linux/debugobjects.h>
+#include <linux/lockdep.h>
+#include <linux/kmemleak.h>
+#include <linux/pid_namespace.h>
+#include <linux/device.h>
+#include <linux/kthread.h>
+#include <linux/sched.h>
+#include <linux/signal.h>
+#include <linux/idr.h>
+#include <linux/kgdb.h>
+#include <linux/ftrace.h>
+#include <linux/async.h>
+#include <linux/sfi.h>
+#include <linux/shmem_fs.h>
+#include <linux/slab.h>
+#include <linux/perf_event.h>
+#include <linux/file.h>
+#include <linux/ptrace.h>
+#include <linux/blkdev.h>
+#include <linux/elevator.h>
+
+#include <asm/io.h>
+#include <asm/bugs.h>
+#include <asm/setup.h>
+#include <asm/sections.h>
+#include <asm/cacheflush.h>
+
+#ifdef CONFIG_X86_LOCAL_APIC
+#include <asm/smp.h>
+#endif
+
+
+void __init my_start_kernel(void)
+{
+    int i = 0;
+    while(1)
+    {
+        i++;
+        if(i%100000 == 0)
+            pr_notice("my_start_kernel here  %d \n",i);
+            
+    }
+}
diff -Naur linux-5.4.34/mykernel/README.md linux-5.4.34-mykernel/mykernel/README.md
--- linux-5.4.34/mykernel/README.md	1970-01-01 08:00:00.000000000 +0800
+++ linux-5.4.34-mykernel/mykernel/README.md	2020-04-25 22:18:46.512717811 +0800
@@ -0,0 +1,21 @@
+mykernel 2.0
+==========
+Develop your own OS kernel by reusing Linux infrastructure, based on x86-64/Linux Kernel 5.4.34.
+
+## Set up mykernel 2.0 in Ubuntu 18.04
+
+```
+sudo apt install build-essential
+sudo apt install axel
+sudo apt install qemu # install QEMU
+sudo apt install libncurses-dev bison flex libssl-dev libelf-dev
+wget https://raw.github.com/mengning/mykernel/master/mykernel-2.0_for_linux-5.3.34.patch
+axel -n 20 https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.4.34.tar.xz
+xz -d linux-5.4.34.tar.xz
+tar -xvf linux-5.4.34.tar
+cd linux-5.4.34
+patch -p1 < ../mykernel-2.0_for_linux-5.3.34.patch
+make defconfig # Default configuration is based on 'x86_64_defconfig'
+make -j$(nproc)
+qemu-system-x86_64 -kernel arch/x86/boot/bzImage
+```

1.3 下載內核

sudo axel -n 20 https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.4.34.tar.xz
xz -d linux-5.4.34.tar.xz
tar -xvf linux-5.4.34.tar

1.4 安裝補丁

cd linux-5.4.34
sudo apt install patch
patch -p1 < ../mykernel-2.0_for_linux-5.4.34.patch

1.5 編譯內核

在虛擬機環境下,如果物理機支持超線程,可以配置虛擬機為雙核四線程。

編譯時間大致四五分鐘左右,如果虛擬機預設配置單核單線程,使用defconfig需要較長的編譯時間。

sudo apt install build-essential libncurses-dev bison flex libssl-dev libelf-dev
make defconfig
make -j$(nproc)

1.6 安裝QEMU模擬器

此處QEMU用於模擬硬體設備,通過模擬一臺獨立運行操作系統的虛擬機,運行編譯後的系統。

sudo apt install qemu # install QEMU
qemu-system-x86_64 -kernel arch/x86/boot/bzImage


至此,Linux內核編譯完成,大致的配置流程為:

  • 下載內核補丁
  • 下載系統內核
  • 通過給系統打補丁後編譯運行,觀察內核運行與中斷的輸出

2 修改內核

首先,在mykernel目錄下創建mypcb.h頭文件:

  • Thread結構體模擬指令指針與堆棧指針

  • PCB結構體實現進程式控制制塊,主要包含進程句柄,狀態,棧,線程信息,進程函數等,next以鏈表形式鏈接進程

#define MAX_TASK_NUM        4
#define KERNEL_STACK_SIZE   1024*2

struct Thread {
    unsigned long		ip;
    unsigned long		sp;
};

typedef struct PCB{
    int pid;
    volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
    unsigned long stack[KERNEL_STACK_SIZE];
    struct Thread thread;
    unsigned long	task_entry;
    struct PCB *next;
}tPCB;

void my_schedule(void);

之後創建myinterrupt.c文件,實現中斷效果以及進程間的切換:

#include "mypcb.h"

extern tPCB task[MAX_TASK_NUM];
extern tPCB * my_current_task;
extern volatile int my_need_sched;
volatile int time_count = 0;

/*
 * Called by timer interrupt.
 * it runs in the name of current running process,
 * so it use kernel stack of current running process
 */
void my_timer_handler(void)
{
    if(time_count%1000 == 0 && my_need_sched != 1)
    {
        printk(KERN_NOTICE ">>>my_timer_handler here<<<\n");
        my_need_sched = 1;
    } 
    time_count ++ ;  
    return;  	
}

void my_schedule(void)
{
    tPCB * next;
    tPCB * prev;

    if(my_current_task == NULL 
        || my_current_task->next == NULL)
    {
    	return;
    }
    printk(KERN_NOTICE ">>>my_schedule<<<\n");
    /* schedule */
    next = my_current_task->next;
    prev = my_current_task;
    if(next->state == 0)
    {        
    	my_current_task = next; 
    	printk(KERN_NOTICE ">>>switch %d to %d<<<\n",prev->pid,next->pid);  
    	/* switch to next process */
    	asm volatile(	
        	"pushq %%rbp\n\t"
        	"movq %%rsp,%0\n\t"
        	"movq %2,%%rsp\n\t"
        	"movq $1f,%1\n\t"
        	"pushq %3\n\t" 
        	"ret\n\t"
        	"1:\t"
        	"popq %%rbp\n\t"
        	: "=m" (prev->thread.sp),"=m" (prev->thread.ip)
        	: "m" (next->thread.sp),"m" (next->thread.ip)
    	); 
    }  
    return;	
}

最後在mymain.c中,根據0號進程fork出其他進程,形成進程的環狀調用:

#include "mypcb.h"

tPCB task[MAX_TASK_NUM];
tPCB * my_current_task = NULL;
volatile int my_need_sched = 0;

void my_process(void);

void __init my_start_kernel(void)
{
    int pid = 0;
    int i;
    /* Initialize process 0*/
    task[pid].pid = pid;
    task[pid].state = 0;
    task[pid].task_entry = task[pid].thread.ip = (unsigned long)my_process;
    task[pid].thread.sp = (unsigned long)&task[pid].stack[KERNEL_STACK_SIZE-1];
    task[pid].next = &task[pid];
    /*fork more process */
    for(i=1;i<MAX_TASK_NUM;i++)
    {
        memcpy(&task[i],&task[0],sizeof(tPCB));
        task[i].pid = i;
	    task[i].thread.sp = (unsigned long)(&task[i].stack[KERNEL_STACK_SIZE-1]);
        task[i].next = task[i-1].next;
        task[i-1].next = &task[i];
    }
    /* start process 0 by task[0] */
    pid = 0;
    my_current_task = &task[pid];
	asm volatile(
    	"movq %1,%%rsp\n\t"
    	"pushq %1\n\t"
    	"pushq %0\n\t"
    	"ret\n\t"
    	: 
    	: "c" (task[pid].thread.ip),"d" (task[pid].thread.sp)
	);
} 

int i = 0;

void my_process(void)
{    
    while(1)
    {
        i++;
        if(i%10000000 == 0)
        {
            printk(KERN_NOTICE "this is process %d -\n",my_current_task->pid);
            if(my_need_sched == 1)
            {
                my_need_sched = 0;
        	    my_schedule();
        	}
        	printk(KERN_NOTICE "this is process %d +\n",my_current_task->pid);
        }     
    }
}

以上代碼的核心在於兩段內嵌彙編代碼,mymain.c與myinterrupt.c中分別實現了0號進程的啟動與進程間切換:

asm volatile(
    	"movq %1,%%rsp\n\t" 	/* set task[pid].thread.sp to rsp */
    	"pushq %1\n\t" 	        /* push rbp */
    	"pushq %0\n\t" 	        /* push task[pid].thread.ip */
    	"ret\n\t" 	        /* pop task[pid].thread.ip to rip */
    	: 
    	: "c" (task[pid].thread.ip),"d" (task[pid].thread.sp)	/* input c or d mean %ecx/%edx*/
	);

mymain.c中將0號進程棧頂信息存入rsp寄存器,通過將當前進程rbp與指令指針壓棧,再借用ret指令返回0號進程ip指向的my_process函數執行。

asm volatile(	
        	"pushq %%rbp\n\t" 	/* save rbp of prev */
        	"movq %%rsp,%0\n\t" 	/* save rsp of prev */
        	"movq %2,%%rsp\n\t"     /* restore  rsp of next */
        	"movq $1f,%1\n\t"       /* save rip of prev */	
        	"pushq %3\n\t" 
        	"ret\n\t" 	        /* restore  rip of next */
        	"1:\t"                  /* next process start here */
        	"popq %%rbp\n\t"
        	: "=m" (prev->thread.sp),"=m" (prev->thread.ip)
        	: "m" (next->thread.sp),"m" (next->thread.ip)
    	); 

myinterrupt.c中先將當前的rbp壓棧,然後保存當前進程的rsp信息,完成後將其更新為下一個進程的rsp。

之後將即將運行的進程IP入棧,通過ret指令將下一個進程的IP送入rip寄存器。

最後將切換後的進程堆棧基地址從堆棧中恢復到rbp寄存器中。

3 核心功能

Linux操作系統主要有以下核心功能:

  • 進程管理

    負責管理CPU資源,以便讓各個進程可以以儘量公平的方式訪問CPU。

  • 記憶體管理

    負責管理Memory(記憶體)資源,以便讓各個進程可以安全地共用機器的記憶體資源。

  • 文件系統

    Linux內核將不同功能的外部設備,抽象為統一的文件操作介面(open、close、read、write等)。

  • 網路管理

    負責管理系統的網路設備,並實現各類網路標準。

  • 硬體驅動

    將系統操作映射到物理設備,除了處理器,記憶體等個別實體外,一般設備控制操作都由定址設備相關的代碼進行。

  • 進程間通信

    不管理硬體,只負責Linux系統中進程之間的通信。


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 視頻:https://www.bilibili.com/video/BV15x411x7WN?p=7 ChartControl圖表控制項的運用。 選擇一種圖表類型,先不考慮各種圖表的疊加。 綁定數據,設置橫坐標和縱坐標。 private void XtraForm1_Load(object sende ...
  • 0. 前言 在上一篇中,我故意留下了查詢的示範沒講。雖然說可以通過以下代碼獲取一個DataReader: 然後通過reader一行一行的讀取數據,但是我並不推薦這樣使用。 在查詢這一高頻需求上,C 為之做了很多工作,提供了更多的選擇。這裡介紹一個查詢的另一套寫法。 1. 離線查詢 C 在查詢上提供了 ...
  • 依賴倒置原則(DIP) 依賴倒置(Dependency Inversion Principle,縮寫DIP)是面向對象六大基本原則之一。他是指一種特定的的解耦形式,使得高層次的模塊不依賴低層次的模塊的實現細節,依賴關係被顛倒(反轉),從而使得低層次模塊依賴於高層次模塊的需求抽象. 該原則規定: 高層 ...
  • 本文屬於OData系列 目錄(可能會有後續修改) "武裝你的WEBAPI OData入門" 武裝你的WEBAPI OData便捷查詢 武裝你的WEBAPI OData分頁查詢 武裝你的WEBAPI OData資源更新 武裝你的WEBAPI OData之EDM 武裝你的WEBAPI OData格式轉換 ...
  • 距離上次提出 [Asp.Net Core] Blazor Server Side 擴展用途 - 配合CEF來製作帶瀏覽器核心的客戶端軟體 的想法後, 差不多2個星期了. 這個玩意也做了一半, 自用是沒問題的, 放出去倒是不夠精細. 如圖: 上面的是開發中的項目文件的截圖. 不是成品. 現在可以用 . ...
  • 這段時間,小豬羅志祥正處於風口浪尖,具體是為啥?還不知道的小伙伴趕緊去補一下最近的娛樂圈八卦~簡單來說,就是我們的小羅同事,以自己超強的體力,以及超強的時間管理能力,重新定義了「多人運動」的含義,重新刷新了大眾對 40 歲男人的印象。 所以啊,像手機這種很有隱私性的產品,一定要設置好各種限制,否則就 ...
  • 1. 破解 2. 安裝支持包 (1)為了訪問matlab時不用加路徑,添加環境變數可在 /etc/profile中添加以下代碼 (2)為了防止可能的錯誤,安裝MATLAB的支持包,在終端輸入以下代碼 3. 建立快捷方式 (1).在網上下載一張matlab的圖片,保存為matlab_logo.png, ...
  • Infi-chu: http://www.cnblogs.com/Infi-chu/ 在top和ps命令中有一列顯示進程狀態,分別有如下值: 值 含義 S 進程處於interruptable sleep D 進程處於uninterruptable sleep R 進程處於運行狀態 Z 進程處於僵屍狀 ...
一周排行
    -Advertisement-
    Play Games
  • 基於.NET Framework 4.8 開發的深度學習模型部署測試平臺,提供了YOLO框架的主流系列模型,包括YOLOv8~v9,以及其系列下的Det、Seg、Pose、Obb、Cls等應用場景,同時支持圖像與視頻檢測。模型部署引擎使用的是OpenVINO™、TensorRT、ONNX runti... ...
  • 十年沉澱,重啟開發之路 十年前,我沉浸在開發的海洋中,每日與代碼為伍,與演算法共舞。那時的我,滿懷激情,對技術的追求近乎狂熱。然而,隨著歲月的流逝,生活的忙碌逐漸占據了我的大部分時間,讓我無暇顧及技術的沉澱與積累。 十年間,我經歷了職業生涯的起伏和變遷。從初出茅廬的菜鳥到逐漸嶄露頭角的開發者,我見證了 ...
  • C# 是一種簡單、現代、面向對象和類型安全的編程語言。.NET 是由 Microsoft 創建的開發平臺,平臺包含了語言規範、工具、運行,支持開發各種應用,如Web、移動、桌面等。.NET框架有多個實現,如.NET Framework、.NET Core(及後續的.NET 5+版本),以及社區版本M... ...
  • 前言 本文介紹瞭如何使用三菱提供的MX Component插件實現對三菱PLC軟元件數據的讀寫,記錄了使用電腦模擬,模擬PLC,直至完成測試的詳細流程,並重點介紹了在這個過程中的易錯點,供參考。 用到的軟體: 1. PLC開發編程環境GX Works2,GX Works2下載鏈接 https:// ...
  • 前言 整理這個官方翻譯的系列,原因是網上大部分的 tomcat 版本比較舊,此版本為 v11 最新的版本。 開源項目 從零手寫實現 tomcat minicat 別稱【嗅虎】心有猛虎,輕嗅薔薇。 系列文章 web server apache tomcat11-01-官方文檔入門介紹 web serv ...
  • 1、jQuery介紹 jQuery是什麼 jQuery是一個快速、簡潔的JavaScript框架,是繼Prototype之後又一個優秀的JavaScript代碼庫(或JavaScript框架)。jQuery設計的宗旨是“write Less,Do More”,即倡導寫更少的代碼,做更多的事情。它封裝 ...
  • 前言 之前的文章把js引擎(aardio封裝庫) 微軟開源的js引擎(ChakraCore))寫好了,這篇文章整點js代碼來測一下bug。測試網站:https://fanyi.youdao.com/index.html#/ 逆向思路 逆向思路可以看有道翻譯js逆向(MD5加密,AES加密)附完整源碼 ...
  • 引言 現代的操作系統(Windows,Linux,Mac OS)等都可以同時打開多個軟體(任務),這些軟體在我們的感知上是同時運行的,例如我們可以一邊瀏覽網頁,一邊聽音樂。而CPU執行代碼同一時間只能執行一條,但即使我們的電腦是單核CPU也可以同時運行多個任務,如下圖所示,這是因為我們的 CPU 的 ...
  • 掌握使用Python進行文本英文統計的基本方法,並瞭解如何進一步優化和擴展這些方法,以應對更複雜的文本分析任務。 ...
  • 背景 Redis多數據源常見的場景: 分區數據處理:當數據量增長時,單個Redis實例可能無法處理所有的數據。通過使用多個Redis數據源,可以將數據分區存儲在不同的實例中,使得數據處理更加高效。 多租戶應用程式:對於多租戶應用程式,每個租戶可以擁有自己的Redis數據源,以確保數據隔離和安全性。 ...