当前位置: 首页 > news >正文

【计算机科学速成课】笔记三——操作系统

文章目录

    • 18.操作系统
      • 问题引出——
      • 批处理
      • 设备驱动程序
      • 多任务处理
      • 虚拟内存
      • 内存保护
      • Unix

18.操作系统

在这里插入图片描述

问题引出——

Computers in the 1940s and early 50s ran one program at a time.
1940,1950 年代的电脑,每次只能运行一个程序

A programmer would write one at their desk, for example, on punch cards.
程序员在打孔纸卡上写程序

Then, they’d carry it to a room containing a room-sized computer,
然后拿到一个计算机房间, 交给操作员

and hand it to a dedicated computer operator.
That person would then feed the program into the computer when it was next available.
等计算机空下来了,操作员会把程序放入

The computer would run it, spit out some output, and halt.
然后运行,输出结果,停机
在这里插入图片描述

This very manual process worked OK back when computers were slow,
以前计算机慢,这种手动做法可以接受

and running a program often took hours, days or even weeks.
运行一个程序通常要几小时,几天甚至几周

But, as we discussed last episode,
但上集说过,计算机越来越快,越来越快

computers became faster… and faster… and faster

exponentially so!
指数级增长!

Pretty soon, having humans run around and inserting programs into readers
很快,放程序的时间 比程序运行时间还长

在这里插入图片描述

was taking longer than running the actual programs themselves.
We needed a way for computers to operate themselves,
我们需要一种方式 让计算机自动运作

and so, operating systems were born.
于是"操作系统"诞生了

Operating systems , or OS for short, are just programs.
操作系统,简称 OS,其实也是程序

But, special privileges on the hardware let them run and manage other programs.
但它有操作硬件的特殊权限 \N 可以运行和管理其它程序

They’re typically the first one to start when a computer is turned on,
操作系统一般是开机第一个启动的程序

and all subsequent programs are launched by the OS.
其他所有程序 都由操作系统启动

They got their start in the 1950s,
操作系统开始于 1950 年代 \N 那时计算机开始变得更强大更流行

批处理

as computers became more widespread and more powerful.
The very first OS augmented the mundane, manual task of loading programs by hand.
第一个操作系统 加强了程序加载方式

Instead of being given one program at a time,
之前只能一次给一个程序,现在可以一次多个
computers could be given batches.

When the computer was done with one,
当计算机运行完一个程序,会自动运行下一个程序
it would automatically and near-instantly start the next.
There was no downtime while someone scurried around an office to find the next program to run.
这样就不会浪费时间,找下一个程序的纸卡

This was called batch processing .
这叫 批处理

设备驱动程序

While computers got faster, they also got cheaper.
电脑变得更快更便宜,开始在出现在世界各地

So, they were popping up all over the world,
especially in universities and government offices.
特别是大学和政府办公室

Soon, people started sharing software.
很快,人们开始分享软件,但有一个问题

But there was a problem
In the era of one-off computers, like the Harvard Mark 1 or ENIAC,
在哈佛1号和 ENIAC 那个时代,计算都是一次性的

programmers only had to write code for that one single machine.
程序员只需要给那"一台"机器写代码

The processor, punch card readers, and printers were known and unchanging.
处理器,读卡器,打印机都是已知的
在这里插入图片描述

But as computers became more widespread,
但随着电脑越来越普遍,计算机配置并不总是相同的

their configurations were not always identical,
like computers might have the same CPU, but not the same printer.
比如计算机可能有相同 CPU,但不同的打印机

This was a huge pain for programmers.
这对程序员很痛苦

Not only did they have to worry about writing their program,
不仅要担心写程序,还要担心程序怎么和不同型号打印机交互

but also how to interface with each and every model of printer,
and all devices connected to a computer, what are called peripherals.
以及计算机连着的其他设备,这些统称"外部设备"

Interfacing with early peripherals was very low level,
和早期的外部设备交互,是非常底层的

requiring programmers to know intimate hardware details about each device.
程序员要了解设备的硬件细节

On top of that, programmers rarely had access to every model of a peripheral to test their code on.
加重问题的是,程序员很少能拿到所有型号的设备来测代码

So, they had to write code as best they could, often just by reading manuals,
所以一般是阅读手册来写代码,祈祷能正常运行

and hope it worked when shared.

Things weren’t exactly plug-and-play
现在是"即插即用",以前是"祈祷能用"

back then more plug-and-pray.

This was clearly terrible,
这很糟糕,所以为了程序员写软件更容易

so to make it easier for programmers,

Operating Systems stepped in as intermediaries between software programs and hardware peripherals.
操作系统充当软件和硬件之间的媒介

More specifically, they provided a software abstraction, through APIs,
更具体地说,操作系统提供 API 来抽象硬件,叫"设备驱动程序"

called device drivers .
These allow programmers to talk to common input and output hardware,
程序员可以用标准化机制 和输入输出硬件(I/O)交互

or I/O for short, using standardized mechanisms.

For example, programmers could call a function like “print highscore”,
比如,程序员只需调用 print(highscore)

and the OS would do the heavy lifting to get it onto paper.
操作系统会处理 输到纸上的具体细节

多任务处理

By the end of the 1950s, computers had gotten so fast,
到 1950 年代尾声,电脑已经非常快了

they were often idle waiting for slow mechanical things, like printers and punch card readers.
处理器经常闲着,等待慢的机械设备(比如打印机和读卡器)

While programs were blocked on I/O,
程序阻塞在 I/O 上

the expensive processor was just chillin’… not like a villain
而昂贵的处理器则在度假,就是放松啥也不做

you know, just relaxing.
In the late 50’s, the University of Manchester, in the UK,
50年代后期,英国曼彻斯特大学 \N 开始研发世界上第一台超级计算机,Atlas

started work on a supercomputer called Atlas, one of the first in the world.
They knew it was going to be wicked fast,
他们知道机器会超级快,所以需要一种方式来最大限度的利用它

so they needed a way to make maximal use of the expensive machine.

Their solution was a program called the Atlas Supervisor, finished in 1962.
他们的解决方案是一个程序叫 Atlas Supervisor \N 于1962年完成

This operating system not only loaded programs automatically, like earlier batch systems,
这个操作系统 \N不仅像更早期的批处理系统那样,能自动加载程序

but could also run several at the same time on its single CPU.
还能在单个 CPU 上同时运行几个程序

It did this through clever scheduling.
它通过调度来做到这一点

Let’s say we have a game program running on Atlas,
假设 Atlas 上有一个游戏在运行

and we call the function “print(highscore)”
并且我们调用一个函数 print(highscore)

which instructs Atlas to print the value of a variable named “highscore”
它让 Atlas 打印一个叫 highscore 的变量值

onto paper to show our friends that we’re the ultimate champion of virtual tiddlywinks.
让朋友知道 我是最高分冠军

That function call is going to take a while, the equivalent of thousands of clock cycles,
print 函数运行需要一点时间,大概上千个时钟周期

because mechanical printers are slow in comparison to electronic CPUs.
但因为打印机比 CPU 慢,与其等着它完成操作

So instead of waiting for the I/O to finish,
Atlas instead puts our program to sleep,
Atlas 会把程序休眠,运行另一个程序

then selects and runs another program that’s waiting and ready to run.
Eventually, the printer will report back to Atlas that it finished printing the value of “highscore”.
最终, 打印机会告诉 Atlas, 打印已完成

Atlas then marks our program as ready to go,
Atlas 会把程序标记成可继续运行

and at some point, it will be scheduled to run again on the CPU,
之后在某时刻会安排给 CPU 运行

and continue onto the next line of code following the print statement.
并继续 print 语句之后的下一行代码

In this way, Atlas could have one program running calculations on the CPU,
这样, Atlas 可以在 CPU 上运行一个程序

while another was printing out data,
同时另一个程序在打印数据

and yet another reading in data from a punch tape.
同时另一个程序读数据

Atlas’ engineers doubled down on this idea,
Atlas 的工程师做的还要多,配了4台纸带读取器,4台纸带打孔机

and outfitted their computer with 4 paper tape readers, 4 paper tape punches,
and up to 8 magnetic tape drives.
多达8个磁带驱动器

This allowed many programs to be in progress all at once,
使多个程序可以同时运行,在单个 CPU 上共享时间

sharing time on a single CPU.
This ability, enabled by the Operating System, is called
操作系统的这种能力叫**“多任务处理”**
multitasking.

虚拟内存

There’s one big catch to having many programs running simultaneously on a single computer, though.
同时运行多个程序有个问题

Each one is going to need some memory,
每个程序都会占一些内存 \N 当切换到另一个程序时,我们不能丢失数据

and we can’t lose that program’s data when we switch to another program.
The solution is to allocate each program its own block of memory.
解决办法是 给每个程序分配专属内存块

So, for example, let’s say a computer has 10,000 memory locations in total.
举个例子,假设计算机一共有 10000 个内存位置

Program A might get allocated memory addresses 0 through 999,
程序 A 分配到内存地址 0 到 999

and Program B might get 1000 through 1999, and so on.
而程序 B 分配到内存地址 1000 到 1999,以此类推
在这里插入图片描述

If a program asks for more memory,
如果一个程序请求更多内存,操作系统会决定是否同意

the operating system decides if it can grant that request,
and if so, what memory block to allocate next.
如果同意,分配哪些内存块

This flexibility is great, but introduces a quirk.
这种灵活性很好,但带来一个奇怪的后果

It means that Program A could end up being allocated non-sequential blocks of memory,
程序 A 可能会分配到非连续的内存块

in say addresses 0 through 999, and 2000 through 2999.
比如内存地址 0 到 999,以及 2000 到 2999

And this is just a simple example
这只是个简单例子

  • a real program might be allocated dozens of blocks scattered all over memory.
    真正的程序可能会分配到内存中数十个地方

As you might imagine,
你可能想到了,这对程序员来说很难跟踪

this would get really confusing for programmers to keep track of.
Maybe there’s a long list of sales data in memory that
也许内存里有一长串销售额,每天下班后要算销售总额

a program has to total up at the end of the day,
but this list is stored across a bunch of different blocks of memory.
但列表 存在一堆不连续的内存块里

To hide this complexity, Operating Systems virtualize memory locations.
为了隐藏这种复杂性,操作系统会把内存地址进行 “虚拟化”

With Virtual Memory, programs can assume their memory always starts at address 0,
这叫 “虚拟内存”,程序可以假定内存总是从地址0开始

keeping things simple and consistent.
简单又一致

However, the actual, physical location in computer memory
而实际物理位置 被操作系统隐藏和抽象了

is hidden and abstracted by the operating system.
而实际物理位置 被操作系统隐藏和抽象了

Just a new level of abstraction.
一层新的抽象

Let’s take our example Program B,
用程序 B 来举例 \N 它被分配了内存地址 1000 到 1999

which has been allocated a block of memory from address 1000 to 1999.
As far as Program B can tell, this appears to be a block from 0 to 999.
对程序 B 而言,它看到的地址是 0 到 999
在这里插入图片描述
虚拟内存可以相同的

The OS and CPU handle the virtual-to-physical memory remapping automatically.
操作系统会自动处理 \N 虚拟内存和物理内存之间的映射

So, if Program B requests memory location 42,
如果程序 B 要地址 42,实际上是物理地址 1042

it really ends up reading address 1042.
如果程序 B 要地址 42,实际上是物理地址 1042

This virtualization of memory addresses is even more useful for Program A,
这种内存地址的虚拟化 对程序 A 甚至更有用

which in our example, has been allocated two blocks of memory
在例子中,A 被分配了两块隔开的内存

that are separated from one another.
This too is invisible to Program A.
程序 A 不知道这点.

As far as it can tell, it’s been allocated a continuous block of 2000 addresses.
以 A 的视角,它有 2000 个连续地址

When Program A reads memory address 999,
当程序 A 读内存地址 999 时 \N 会刚好映射到物理内存地址 999

that does coincidentally map to physical memory address 999.
But if Program A reads the very next value in memory, at address 1000,
但如果程序 A 读下一个地址 1000

that gets mapped behind the scenes to physical memory address 2000.
会映射到物理地址 2000

This mechanism allows programs to have flexible memory sizes,
这种机制使程序的内存大小可以灵活增减 \N 叫"动态内存分配"

called dynamic memory allocation,
that appear to be continuous to them.
对程序来说,内存看起来是连续的.

It simplifies everything and offers tremendous flexibility to the Operating System
它简化了一切,为操作系统同时运行多个程序 \N 提供了极大的灵活性

in running multiple programs simultaneously.
Another upside of allocating each program its own memory,
给程序分配专用的内存范围,\N 另一个好处是 这样隔离起来会更好

内存保护

is that they’re better isolated from one another.
给程序分配专用的内存范围,\N 另一个好处是 这样隔离起来会更好

So, if a buggy program goes awry, and starts writing gobbledygook,
如果一个程序出错,开始写乱七八糟的数据

it can only trash its own memory, not that of other programs.
它只能捣乱自己的内存,不会影响到其它程序.

This feature is called Memory Protection.
这叫 “内存保护

This is also really useful in protecting against malicious software, like viruses.
防止恶意软件(如病毒)也很有用

For example, we generally don’t want other programs to have the ability
例如,我们不希望其他程序有能力 \N 读或改邮件程序的内存

to read or modify the memory of, let say, our email,
with that kind of access,
如果有这种权限 \N 恶意软件可能以你的名义发邮件,甚至窃取个人信息
malware could send emails on your behalf and maybe steal personal information.
Not good!
一点都不好!

Atlas had both virtual and protected memory.
Atlas 既有"虚拟内存"也有"内存保护"

It was the first computer and OS to support these features!
是第一台支持这些功能的计算机和操作系统!

By the 1970s, computers were sufficiently fast and cheap.
到 1970 年代,计算机足够快且便宜

Institutions like a university could buy a computer and let students use it.
大学会买电脑让学生用

It was not only fast enough to run several programs at once,
计算机不仅能同时运行多个程序,还能让多用户能同时访问
but also give several users simultaneous, interactive access.
This was done through a terminal,
多个用户用"终端"来访问计算机

which is a keyboard and screen that connects to a big computer,
"终端"只是键盘+屏幕,连到主计算机 \N 终端本身没有处理能力

but doesn’t contain any processing power itself.
A refrigerator-sized computer might have 50 terminals connected to it,
冰箱大小的计算机可能有50个终端,能让50个用户使用

allowing up to 50 users.
Now operating systems had to handle not just multiple programs,
这时操作系统不但要处理多个程序,还要处理多个用户

but also multiple users.
So that no one person could gobble up all of a computer’s resources,
为了确保其中一个人 不会占满计算机资源

operating systems were developed that offered time-sharing.
开发了 分时操作系统

With time-sharing each individual user was only allowed to utilize
意思是 每个用户只能用一小部分处理器,内存等

a small fraction of the computer’s processor, memory, and so on.
意思是 每个用户只能用一小部分处理器,内存等

Because computers are so fast,
因为电脑很快 \N 即使拿到 1/50 的资源也足以完成许多任务

even getting just 1/50th of its resources was enough for individuals to complete many tasks.
因为电脑很快 \N 即使拿到 1/50 的资源也足以完成许多任务

The most influential of early time-sharing Operating Systems was
早期分时操作系统中,最有影响力的是 \N Multics(多任务信息与计算系统)

Multics, or Multiplexed Information and Computing Service,
早期分时操作系统中,最有影响力的是 \N Multics(多任务信息与计算系统)

released in 1969.
于 1969 年发布

Unix

Multics was the first major operating system designed to be secure from the outset.
Multics 是第一个,从设计时就考虑到安全的操作系统

Developers didn’t want mischievous users accessing data they shouldn’t,
开发人员不希望恶意用户 访问不该访问的数据

like students attempting to access the final exam on their professor’s account.
比如学生假装成教授,访问期末考试的文件

Features like this meant Multics was really complicated for its time,
这导致 Multics 的复杂度超过当时的平均水准

using around 1 Megabit of memory, which was a lot back then!
操作系统会占大约 1 Mb 内存,这在当时很多!

That might be half of a computer’s memory, just to run the OS!
可能是内存的一半,只拿来运行操作系统!

Dennis Ritchie, one of the researchers working on Multics, once said:
Multics 的研究人员之一 Dennis Ritchie 曾说过

"One of the obvious things that went wrong with Multics as a commercial success
"阻碍 Multics 获得商业成功的一个明显问题是

was just that it was sort of over-engineered in a sense.
从某种方面来说,它被过度设计了,功能太多了"

There was just too much in it."
This lead Dennis, and another Multics researcher,
所以 Dennis 和另一个 Multics 研究员 \N Ken Thompson 联手打造新的操作系统

Ken Thompson, to strike out on their own and build a new, lean operating system
called Unix.
Unix

They wanted to separate the OS into two parts:
他们想把操作系统分成两部分

First was the core functionality of the OS,
首先是操作系统的核心功能

things like memory management, multitasking,and dealing with I/O,
如内存管理,多任务和输入/输出处理 \N 这叫"内核"

which is called the kernel .
如内存管理,多任务和输入/输出处理 \N 这叫"内核"

The second part was a wide array of useful tools that came bundled with,
第二部分是一堆有用的工具

but not part of the kernel, things like programs and libraries.
但它们不是内核的一部分(比如程序和运行库)

Building a compact, lean kernel meant intentionally leaving some functionality out.
紧凑的内核 意味着功能没有那么全面

Tom Van Vleck, another Multics developer, recalled:
Multics 的另一个开发者 Tom Van Vleck 回忆说:

“I remarked to Dennis that easily half the code I was writing in Multics was error recovery code.”
“我对 Dennis 说,我在 Multics 写的一半代码都是错误恢复代码”

He said, "We left all that stuff out of Unix.
他说:"Unix 不会有这些东西

If there’s an error, we have this routine called panic,
如果有错误发生,我们就让内核"恐慌"(panic)

and when it is called, the machine crashes,
当调用它时,机器会崩溃

and you holler down the hall, ‘Hey, reboot it.’“”
你得在走廊里大喊,“嘿,重启电脑”

You might have heard of kernel panics.
你可能听过 “内核恐慌”(kernel panic)

This is where the term came from.
这就是这个词的来源

It’s literally when the kernel crashes, has no recourse to recover,
内核如果崩溃,没有办法恢复

and so calls a function called “panic”.
所以调用一个叫"恐慌"(panic)的函数

Originally, all it did was print the word “panic” and then enter an infinite loop.
起初只是打印"恐慌"一词,然后无限循环

This simplicity meant that Unix could be run on cheaper and more diverse hardware,
这种简单性意味着 \N Unix 可以在更便宜更多的硬件上运行

making it popular inside Bell Labs, where Dennis and Ken worked.
使 Unix 在 Dennis 和 Ken 工作的 \N 贝尔实验室大受欢迎

As more developers started using Unix to build and run their own programs,
越来越多开发人员用 Unix 写程序和运行程序

the number of contributed tools grew.
工具数量日益增长

Soon after its release in 1971,
1971 年发布后不久

it gained compilers for different programming languages and even a word processor,
就有人写了不同编程语言的编译器 \N 甚至文字处理器

quickly making it one of the most popular OSes of the 1970s and 80s.
使得 Unix 迅速成为 \N 1970~80年代最流行的操作系统之一

At the same time, by the early 1980s,
到 1980 年代早期

the cost of a basic computer had fallen to the point where individual people could afford one,
计算机的价格 降到普通人买得起 \N 这些叫"个人电脑"或"家庭电脑"

called a personal or home computer.

These were much simpler than the big mainframes
这些电脑比大型主机简单得多 \N 主机一般在大学,公司和政府
found at universities, corporations, and governments.
So, their operating systems had to be equally simple.
因此操作系统也得简单

For example, Microsoft’s Disk Operating System, or MS-DOS, was just 160 kilobytes,
举例,微软的磁盘操作系统(MS-DOS)只有 160 kB \N 一张磁盘就可以容纳
在这里插入图片描述

allowing it to fit, as the name suggests, onto a single disk.
First released in 1981, it became the most popular OS for early home computers,
于 1981 年发布,成为早期家用电脑最受欢迎的操作系统

even though it lacked multitasking and protected memory.
虽然缺少"多任务"和"保护内存"这样功能

This meant that programs could,
意味着程序经常使系统崩溃

and would, regularly crash the system.
While annoying, it was an acceptable tradeoff,
虽然很讨厌但还可以接受,因为用户可以重启
as users could just turn their own computers off and on again!
Even early versions of Windows,
哪怕是微软 1985 年发布的早期 Windows \N 虽然在 90 年代很流行

first released by Microsoft in 1985 and which dominated the OS scene throughout the 1990s,
lacked strong memory protection.
但却缺乏"内存保护"

When programs misbehaved,
当程序行为不当时,就会"蓝屏"
you could get the blue screen of death,
a sign that a program had crashed so badly that it took down the whole operating system.
代表程序崩溃的非常严重,把系统也带崩溃了

Luckily, newer versions of Windows have better protections and usually don’t crash that often.
幸运的是,新版Windows有更好的保护,不会经常崩溃

Today, computers run modern operating systems,
如今的计算机 有现代操作系统

like Mac OS X, Windows 10, Linux, iOS and Android.
比如 Mac OS X,Windows 10 \NLinux,iOS和Android

Even though the computers we own are most often used by just a single person,
虽然大部分设备只有一个人使用

you!
你!

their OS all have multitasking and virtual and protected memory.
操作系统依然有**"多任务, “虚拟内存”, “内存保护”**

So, they can run many programs at once:
因此可以同时运行多个程序:

you can watch YouTube in your web browser,
一边在浏览器看 YouTube,一边在 Photoshop 修图

edit a photo in Photoshop,

play music in Spotify and sync Dropbox all at the same time.
用 Spotify 放音乐,同步 Dropbox

This wouldn’t be possible without those decades of research and development on Operating Systems,
如果没有操作系统这几十年的发展,这些都不可能,

and of course the proper memory to store those programs.
当然,我们也需要地方放程序

Which we’ll get to next week.
下周会讨论

相关文章:

【计算机科学速成课】笔记三——操作系统

文章目录 18.操作系统问题引出——批处理设备驱动程序多任务处理虚拟内存内存保护Unix 18.操作系统 问题引出—— Computers in the 1940s and early 50s ran one program at a time. 1940,1950 年代的电脑,每次只能运行一个程序 A programmer would write one at…...

用js代码实现贪吃蛇小游戏

js已经学了大部分了,现在就利用我所学的js知识试试做贪吃蛇小游戏吧 以下部分相关图片以及思路笔记均出自渡一陈老师的视频 首先制作简单的静态页面,添加贪吃蛇移动的背景和相关图片,比如开始游戏等等 将各个功能均封装在函数中&#xff0…...

微信小程序+esp8266温湿度读取

本文主要使用微信小程序显示ESP8266读取的温湿度并通过微信小程序控制LED灯。小程序界面如下图所示 原理讲解 esp8266 通过mqtt发布消息,微信小程序通过mqtt 订阅消息,小程序订阅后,就可以实时收到esp8266 传输来的消息。 个人可免费注册五个微信小程序账号,在微信小程序官…...

软考中级-软件设计师(十)网络与信息安全基础知识

一、网络概述 1.1计算机网络的概念 计算机网络的发展:具有通信功能的单机系统->具有通信功能的多机系统->以共享资源为目的的计算机网络->以局域网及因特网为支撑环境的分布式计算机系统 计算机网络的功能:数据通信、资源共享、负载均衡、高…...

推荐一个好用的命令行工具ShellGPT

ShellGPT 配置安装常用功能聊天写命令并执行 高级功能函数调用角色管理 总结 这两天突然想到,现有的很多工具都在被大模型重构,比如诞生了像perplexity.ai 这种新交互形式的搜索引擎,就连wps也推出了AI服务,甚至都可以直接生成ppt…...

Prompt提示词教程 | 提示工程指南 | 提示词示例 入门篇

在上一节中,我们介绍并给出了如何赋能大语言模型的基本示例。如果还没看而且是刚入门的同学建议看下,有个基本概念。 Prompt提示词教程 | 提示工程指南 | 提示工程简介https://blog.csdn.net/HRG520JN/article/details/138523705在本节中,我…...

uniapp + uView动态表单校验

项目需求&#xff1a;动态循环表单&#xff0c;并实现动态表单校验 页面&#xff1a; <u--form label-position"top" :model"tmForm" ref"tmForm" label-width"0px" :rulesrules><div v-for"(element, index) in tmForm…...

【Linux】HTTPS

欢迎来到Cefler的博客&#x1f601; &#x1f54c;博客主页&#xff1a;折纸花满衣 &#x1f3e0;个人专栏&#xff1a;Linux 目录 &#x1f449;&#x1f3fb;HTTPS协议概念&#x1f449;&#x1f3fb;加密为什么要进行加密 &#x1f449;&#x1f3fb;常见的加密方式对称加密…...

语音识别--使用YAMNet识别环境音

⚠申明&#xff1a; 未经许可&#xff0c;禁止以任何形式转载&#xff0c;若要引用&#xff0c;请标注链接地址。 全文共计3077字&#xff0c;阅读大概需要3分钟 &#x1f308;更多学习内容&#xff0c; 欢迎&#x1f44f;关注&#x1f440;【文末】我的个人微信公众号&#xf…...

前端JS必用工具【js-tool-big-box】,邮箱,手机,身份证号,ip地址等正则验证方法学习

这一小节&#xff0c;我们针对前端npm包 js-tool-big-box 的使用做一些讲解&#xff0c;主要是针对项目中&#xff0c;邮箱&#xff0c;手机号&#xff0c;身份证号&#xff0c;ip地址&#xff0c;url格式&#xff0c;邮政编码等验证的方法使用。 目录 1 安装和引入 2 邮箱验…...

notepad++安装 hex-editor插件

打开notepad 点击插件 搜索 hex-editor,点击右侧 安装install 安装成功后&#xff0c;在已安装插件中就有显示了...

Ubuntu18.04设置SSH密钥登录

我们一般使用 VSCode 、MobaXterm、PuTTY等 SSH 客户端来远程管理 Linux 服务器。但是&#xff0c;一般的密码方式登录&#xff0c;容易有密码被暴力破解的问题。所以&#xff0c;一般我们会将 SSH 的端口设置为默认的 22 以外的端口&#xff0c;或者禁用 root 账户登录。但是即…...

自动化运维管理工具----------Ansible模块详细解读

目录 一、自动化运维工具有哪些&#xff1f; 1.1Chef 1.2puppet 1.3Saltstack 二、Ansible介绍 2.1Ansible简介 2.2Ansible特点 2.3Ansible工作原理及流程 2.3.1内部流程 2.3.2外部流程 三、Ansible部署 3.1环境准备 3.2管理端安装 ansible 3.3Ansible相关文件 …...

零基础代码随想录【Day27】|| 39. 组合总和,40.组合总和II, 131.分割回文串

目录 DAY27 39. 组合总和 解题思路&代码 40.组合总和II 解题思路&代码 131.分割回文串 解题思路&代码 DAY27 39. 组合总和 力扣题目链接(opens new window) 给定一个无重复元素的数组 candidates 和一个目标数 target &#xff0c;找出 candidates 中所有…...

实验15 MVC

二、实验项目内容&#xff08;实验题目&#xff09; 编写代码&#xff0c;掌握MVC的用法。 三、源代码以及执行结果截图&#xff1a; inputMenu.jsp&#xff1a; <% page contentType"text/html" %> <% page pageEncoding "utf-8" %> &…...

《Python编程从入门到实践》day21

# 昨日知识点回顾 设置背景颜色 在屏幕中央绘制飞船 # 今日知识点学习 12.5 重构&#xff1a;方法_check_events()和_update_screen() 12.5.1 方法_check_events() import sys import pygame from Settings import Settings from Ship import Shipclass AlienInvasion:"…...

上位机图像处理和嵌入式模块部署(树莓派4b镜像烧录经验总结)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 陆陆续续也烧录了好多次树莓派的镜像了&#xff0c;这里面有的时候很快&#xff0c;有的时候很慢。特别是烧录慢的时候&#xff0c;也不知道是自己…...

简单数据加解密,JS和JAVA同时实现

前端Vue调用Java后端接口中的数据进行加密&#xff0c;以避免敏感数据泄露。 现在实现一个高性能加密方法&#xff0c;用来对数据进行加密后传输。算法包括JS的加密和解密方法&#xff0c;也包括Java的加密解密方法。 可以在前端加密&#xff0c;后端解密。也可以在后端加密&…...

Android Framework中PackageManagerService的深度剖析

摘要 Android操作系统的核心服务之一——PackageManagerService(PMS)&#xff0c;扮演着至关重要的角色&#xff0c;负责维护系统中所有应用程序的生命周期管理。本文旨在全面探讨PMS的功能特性、工作流程、实际应用场景&#xff0c;并对其进行优劣分析&#xff0c;以期为开发者…...

(AI Web、ChatGPT Native、Ai Loading、AI Tools、知豆AI)

目录 1、AI Web 2、ChatGPT Native 3、Ai Loading 4、AI Tools 5、知豆AI 1、AI Web...

VBA 批量处理Excel文件

目录 一. 批量创建Excel文件1.1 VBA的方式1.2 Powershell方式 二. 批量删除文件三. 批量重命名文件四. 合并多个Excel数据到一个Excel文件中 一. 批量创建Excel文件 1.1 VBA的方式 Sub CreateFiles()Dim strPath As String, strFileName As StringDim i As Long, rDim pathSe…...

PG实例连接访问控制

实例访问控制可以控制来自于不同主机&#xff0c;不同用户是否允许访问指定的数据库&#xff0c;以及验证方式。 与oracle中的连接管理器的功能相同&#xff0c;之前有写过一篇oracleCMAN连接管理器的配置实操&#xff1a; 配置oracle连接管理器&#xff08;cman&#xff09;…...

2024-05-07 商业分析-如何在社会层面做一个更好的工具人-记录

摘要: 2024-05-07 商业分析-如何成为一个靠谱的工具人 如何在社会层面做一个更好的工具人 那么今天讲的这个主题呢&#xff0c;对吧&#xff1f;你们一看啊&#xff0c;就觉得这个就不应该我讲是吧啊&#xff0c;但是呢这个逻辑呢我还得跟你们讲一下啊&#xff0c;就是如何成为…...

C++设计模式-创建型设计模式

设计模式 设计模式是什么 设计模式是指在软件开发中&#xff0c;经过验证的&#xff0c;用于解决在特定环境下&#xff0c;重复出现的&#xff0c;特定问题的解决方案&#xff1b;其实就是解决问题的固定套路。但是要慎用设计模式&#xff0c;有一定的工程代码量之后用它比较…...

code-server容器webpack的ws无法连接解决方法

TLDR 通过指定client的wsrul去连接ws devServer.client.webSocketURL ‘wss://<Forwarded uri>/ws’ 拓扑 1、code-server: 用于编写代码、启动webpack dev-server 服务&#xff1b;[https://<domain>:8001] 2、webpack: 用于浏览dev-server服务&#xff1b;[ht…...

leetcode47-Permutations II

分析 给定一个可包含重复数字的序列 nums &#xff0c;按任意顺序 返回所有不重复的全排列。 示例 1&#xff1a; 输入&#xff1a;nums [1,1,2] 输出&#xff1a; [[1,1,2], [1,2,1], [2,1,1]] 题目 由于元素是重复的&#xff0c;要求返回不重复的&#xff0c;所以一定会有…...

246 基于matlab的交流电机动态方程

基于matlab的交流电机动态方程&#xff0c;用于交流电机动态分析。输入电机的额定功率(kW)、电机的额定转速(r/min)、转子外径(m)、铁心长(m)转子槽数、电机极对数 等参数&#xff0c;输出转速变化、力矩变化等结果。程序已调通&#xff0c;可直接运行。 246 交流电机动态 转速…...

7天入门Android开发之第2天——四大组件之活动

一、活动是什么 活动&#xff08;Activity&#xff09;是 Android 应用程序中的一个重要组件&#xff0c;它代表用户界面上的单个窗口&#xff0c;通常会填充整个屏幕。通过活动&#xff0c;可以创建各种各样的用户界面&#xff0c;并控制界面的行为。活动可以包含各种 UI 元素…...

自然语言(NLP)

It’s time for us to learn how to analyse natural language documents, using Natural Language Processing (NLP). We’ll be focusing on the Hugging Face ecosystem, especially the Transformers library, and the vast collection of pretrained NLP models. Our proj…...

学习java第六十天

Advice的类型&#xff1a; &#xff08;1&#xff09;前置通知&#xff08;Before Advice&#xff09;&#xff1a;在连接点&#xff08;Join point&#xff09;之前执行的通知。 &#xff08;2&#xff09;后置通知&#xff08;After Advice&#xff09;&#xff1a;当连接点退…...

OpenFeign修改HttpClient为Apache HttpClient 5

OpenFeign中http client 如果不做特殊配置&#xff0c;OpenFeign默认使用JDK自带的HttpURLConnection发送HTTP请求&#xff0c; 由于默认HttpURLConnection没有连接池、性能和效率比较低。所以修改为Apache HttpClient 5。 总结为两步&#xff1a; 加依赖改yml 具体操作请往…...

【busybox记录】【shell指令】comm

目录 内容来源&#xff1a; 【GUN】【comm】指令介绍 【busybox】【comm】指令介绍 【linux】【comm】指令介绍 使用示例&#xff1a; 逐行比较两个排序后的文件 - 默认输出 逐行比较两个排序后的文件 - 如果一个文件的排序有问题&#xff0c;那么反错&#xff08;默认&…...

工作中遇到的问题,如何解决的

1. gorm update 一条记录的某个字段后&#xff0c;立刻&#xff08;1ms&#xff09;select这条记录&#xff0c;会有读取不到最新结果的情况&#xff1a; transaction已经提交&#xff0c;数据最后也是更新的。 猜测原因&#xff1a;MySQL没能及时把那条很大的record“刷盘”到…...

数据结构(c):队列

目录 &#x1f37a;0.前言 1.什么是队列 2. 队列的实现 2.1定义队列节点 2.2定义队列 2.3队尾入队列 2.4判断队列是否为空 2.5队头出队列 2.6 队列首元素 2.7队尾元素 2.8队列内的元素个数 2.9销毁队列 3.试运行 &#x1f48e;4.结束语 &#x1f37a;0.前言 言C之…...

Vue单页面应用和多页面应用的区别

概念&#xff1a; SPA单页面应用&#xff08;SinglePage Web Application&#xff09;&#xff0c;指只有一个主页面的应用&#xff0c;一开始只需要加载一次js、css等相关资源。所有内容都包含在主页面&#xff0c;对每一个功能模块组件化。单页应用跳转&#xff0c;就是切换…...

php扩展

查看扩展: print_r(get_loaded_extensions());判断扩展: if (!extension_loaded(gd)) {if (!dl...

mac电脑如何安装python及环境搭建

&#xff08;1&#xff09;进入官网&#xff1a;Download Python | Python.org&#xff0c;根据自己电脑选择python (2)这里我选择的是mac,点击&#xff1a;macos&#xff0c;选择最近版本并点击进入 (3)选择mac版本&#xff1a; (4)点击就可以进入下载&#xff1a; (5)下载好之…...

大数据高级阶段面试题(实时)

1.Kafka的producer如何实现幂等性? ①开启幂等性&#xff0c;将Idempotent设置为true ②将ack设置为-1&#xff0c;确保相同的消息只会发送一次&#xff0c;避免重新发送 2.Kafka的ISR和OSR的作⽤分别是什么? ISR是副本和领导者的数据和状态要保持一致&#xff0c;如果出现…...

Material Studio 计算分子静电力、电荷密度以及差分电荷密度

1.先打开Material Studio导入要计算的分子cif文件或者mol文件&#xff0c;直接Flie-Import 2.高斯几何优化一下结构&#xff0c;参数按照我的设置就行&#xff0c;一般通用&#xff0c;后面出问题再调整 3.点完Run后会跳出很多计算过程&#xff0c;不用管&#xff0c;等他计算完…...

华为鸿蒙系统(Huawei HarmonyOS)

华为鸿蒙系统&#xff08;华为技术有限公司开发的分布式操作系统&#xff09; 华为鸿蒙系统&#xff08;HUAWEI HarmonyOS&#xff09;&#xff0c;是华为公司在2019年8月9日于东莞举行的华为开发者大会&#xff08;HDC.2019&#xff09;上正式发布的分布式操作系统。 华为鸿蒙…...

docker jenkins 部署springboot项目

1、创建jenkins容器 1&#xff0c;首先&#xff0c;我们需要创建一个 Jenkins 数据卷&#xff0c;用于存储 Jenkins 的配置信息。可以通过以下命令创建一个数据卷&#xff1a; docker volume create jenkins_data启动 Jenkins 容器并挂载数据卷&#xff1a; docker run -dit…...

记录一个练手的js逆向password

很明显 请求加密了password 全局搜索 有个加密函数(搜不到的可以搜临近的其他的关键字 或者url参数) 搜索的时候一定要仔细分析 我就没有仔细分析 我搞了好久 又是xhr又是hook的(还没hook到) 我当时也是疏忽了 我寻思这个也不是js文件 直到后来 我怎么也找不到 我就猜想 不…...

如何低成本创建个人网站?

目录 前言 网站源代码 虚拟主机或服务器 域名注册或免费二级域名 域名解析 上传源代码压缩包 添加刚刚的域名 成功搭建 失败的解决方案 结语 前言 很多小白都非常想拥有自己的网站&#xff0c;但很多人虽然有了自己的源代码但苦于不知道怎么将其变成所有人都能够访…...

Finder Windows for Mac:双系统窗口,一键切换!

Finder Windows for Mac是一款专为Mac用户设计的实用工具&#xff0c;它模拟了Windows系统的窗口管理功能&#xff0c;让Mac用户也能享受到类似Windows的窗口操作体验。这款软件的主要功能是提供一个浮动面板&#xff0c;帮助用户随时即时访问打开的Finder窗口列表&#xff0c;…...

Hadoop3:集群搭建及常用命令与shell脚本整理(入门篇,从零开始搭建)

一、集群环境说明 1、用VMware安装3台Centos7.9虚拟机 2、虚拟机配置&#xff1a;2C&#xff0c;2G内存&#xff0c;50G存储 3、集群架构设计 从表格中&#xff0c;可以看出&#xff0c;Hadoop集群&#xff0c;主要有2个模块服务&#xff0c;一个是HDFS服务&#xff0c;一个是…...

yolo-world:”目标检测届大模型“

AI应用开发相关目录 本专栏包括AI应用开发相关内容分享&#xff0c;包括不限于AI算法部署实施细节、AI应用后端分析服务相关概念及开发技巧、AI应用后端应用服务相关概念及开发技巧、AI应用前端实现路径及开发技巧 适用于具备一定算法及Python使用基础的人群 AI应用开发流程概…...

vue3 + ts 快速入门(全)

文章目录 学习链接1. Vue3简介1.1. 性能的提升1.2.源码的升级1.3. 拥抱TypeScript1.4. 新的特性 2. 创建Vue3工程2.1. 基于 vue-cli 创建2.2. 基于 vite 创建&#xff08;推荐&#xff09;vite介绍创建步骤项目结构安装插件项目结构总结 2.3. 一个简单的效果Person.vueApp.vue …...

vue2实现面包屑功能

目录 1. store/index.js 2. router/index.js 3. Header.vue 在Vue 2中实现面包屑导航是一种常见的前端实践&#xff0c;它可以帮助用户了解当前页面在网站结构中的位置&#xff0c;并快速导航到上一级或根目录。以下是使用Vue 2实现面包屑导航的基本步骤&#xff1a; 1. st…...

helm安装 AWS Load Balancer Controller

1、创建AmazonEKSLoadBalancerControllerRole角色 亚马逊文档 创建文档 2&#xff09;、使用 eksctl 创建 IAM 角色 a、安装eksctl eksctl安装文档 使用以下命令下载并提取最新版本的 eksctl curl --silent --location "https://github.com/weaveworks/eksctl/releases/l…...

贪吃蛇大作战(C语言--实战项目)

朋友们&#xff01;好久不见。经过一段时间的沉淀&#xff0c;我这篇文章来和大家分享贪吃蛇大作战这个游戏是怎么实现的。 &#xff08;一&#xff09;.贪吃蛇背景了解及效果展示 首先相信贪吃蛇游戏绝对称的上是我们00后的童年&#xff0c;不仅是贪吃蛇还有俄罗斯⽅块&…...