【DragonOS】文件系统和块设备
什么是块设备https://olegkutkov.me/2020/02/10/linux-block-device-driver/
块设备vs字符设备字符设备:以字符为单位进行I/O操作,如键盘、鼠标、串口等块设备:以块为单位进行I/O操作,如硬盘、U盘等
读写单元:字符设备是字节流,块设备是块
访问方式:字符设备是顺序访问,块设备是随机访问
缓存:字符设备不缓存,块设备缓存设备驱动设备驱动表磁盘分区MBR和GPT都是硬盘分区表,在硬盘分区表之后才是我们日常使用的文件系统比如NTFS,FAT32,EXT等。虽然现在MBR已经是一个不常用的硬盘分区表了,但是GPT为了兼容老的硬盘分区表所以在GPT的结构头部加入了MBR。
MBR的组成硬盘首一个扇区存放MBR表,由4个部分组成,分别是主引导记录(Master Boot Record)、数据区、分区表(包含4个分区项)以及结束标志。
在下面表格中展示了这4个部分的偏移位置和简介:
Master Boot Record 是硬盘分区表的引导程序和数据区,一共占用446个字节,BIOS 读取并执行这段代码,如果被破坏系统就无法读取到硬盘上的 ...
微服务
软件架构单体 SOA 微服务
单体架构:将所有功能模块集成在一个应用中,开发、部署、维护都比较简单,但是随着业务的发展,单体应用会变得越来越庞大,开发效率低下,部署困难,维护成本高。
SOA 架构:面向服务的架构,将应用拆分成多个服务,每个服务都是一个独立的功能模块,服务之间通过接口进行通信,服务之间的耦合度低,易于维护和扩展。
微服务架构:微服务架构是 SOA 架构的一种演进,将服务拆分的更细,每个服务都是一个独立的进程,服务之间通过 HTTP、RPC 等方式进行通信,每个服务都有自己的数据库,服务之间的耦合度更低,易于部署和扩展。一句话解释:微服务架构是一种将应用程序拆分为小而自治的服务的软件架构模式。每个服务专注于执行特定的业务功能,并通过轻量级的通信机制进行交互。它提供了独立开发、可扩展和技术多样性的优势。
在微服务架构中,应用程序被拆分为一组小型、独立的服务,每个服务都专注于执行特定的业务功能。这些服务之间通过轻量级的通信机制进行交互,例如使用 HTTP/REST、消息队列或者事件总线。
每个微服务都有自己的代码库、数据库和部署单元。它们可以使用不同的编程语言和技术栈,根 ...
面经
后端开发面经问题
Q:请描述 select、poll、epoll 这三种IO多路复用技术的执行原理
IO 多路复用(IO Multiplexing)是一种在单个线程中同时监控多个文件描述符(如网络套接字、文件等)的方法。当其中任何一个文件描述符变得可读、可写或发生错误时,程序可以进行相应的处理。IO 多路复用的主要目的是提高系统的并发处理能力,尤其是在网络编程中。
常见的 IO 多路复用机制 select:最早的 IO 多路复用机制,支持监控多个文件描述符,但存在文件描述符数量限制和性能问题。 poll:类似于 select,但没有文件描述符数量限制,性能稍有改善。 epoll:Linux 特有的 IO 多路复用机制,性能优于 select 和 poll,适用于大规模并发连接。 kqueue:FreeBSD 和 macOS 上的 IO 多路复用机制,类似于 epoll。
A:select、poll、epoll 都是 IO 多路复用的机制,都是通过一个线程来监听多个文件描述符的可读、可写、异常等事件。select 是最早的实现,poll 是对 select 的改进,epoll ...
数据库系统
推荐网课:【【自用】数据库系统概论学习】 网课教材:数据库系统概述本校课程教材:Database System Concepts 6th Edition
考试相关SQL占比多一点,DMBS少一点
数据,数据库,数据库管理系统,数据库系统
数据:描述事物的符号记录
数据库:按照数据结构来组织、存储和管理数据的仓库
其中数据的三个特点:永久存储,有组织,可共享
数据库管理系统:数据库系统的核心,是一种操纵和管理数据库的软件
数据库系统:由数据库和数据库管理系统组成的集合数据库管理系统 DBMS
数据定义功能
数据组织、存储和管理功能
数据操纵功能
数据库的事务管理和运行管理
数据库的建立和维护功能数据库系统数据库系统一般由数据库、数据库管理系统(及其开发工具) 、应用系统、数据库管理员等组成。
GPTs:学习数据库理论知识是一个非常有益且丰富的过程,因为数据库是现代计算机系统中不可或缺的一部分。为了开始学习数据库理论,我们可以从几个关键的概念和步骤入手。我们将逐步深入每个概念,并使用类比来帮助理解。
第一步:理解基本概念
数据库(Database)数据库就像一个组织良好的数字化 ...
软件体系架构
作业四种风格解决N皇后问题1. 管道-过滤器风格
问题分解为多个子问题,每个子问题由一个过滤器解决
过滤器之间通过管道连接,每个过滤器处理一个子问题
适用于问题可以分解为多个独立子问题的场景
优点:易于理解、易于扩展
缺点:性能较差,过滤器之间的通信开销较大2. 调用-返回风格
3. 回溯法4. 黑板风格relating Structures to Each Other
【CMU 15-445】数据库系统
课程:【CMU 15-445】数据库系统课本:Database System Concepts, 7th Edition, by Silberschatz, Korth, and Sudarshan
Chapter 1
A database-management system (DBMS) consists of a collection of interrelated data and a collection of programs to access those data. The data describe one particular enterprise
ACID 是数据库管理系统(DBMS)中事务处理的四个关键属性的首字母缩写,分别代表原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Durability)。这些属性确保了数据库事务的可靠性和数据的完整性。原子性(Atomicity):原子性确保事务中的所有操作要么全部完成,要么全部不完成。换句话说,事务是不可分割的最小工作单元。如果事务中的任何一个操作失败,整个事务 ...
SIG-MAIN周会分享_0815
Netlink 协议和 uevent 机制的作用原理与设计实现解析
Mentioned issue:#653: sysfs 支持 uevent
主要工作目录:
kernel/src/driver/base/uevent
kernel/src/net/socket/netlink
uevent 机制
关联:设备驱动模型
uevent( user space event)是 内核与用户空间的一种基于netlink机制通信机制,主要用于设备驱动模型,常用于设备的热插拔。
uevent 是 kobject 的一部分,用于在 kobject 状态发生改变时,例如增加、移除等,通知用户空间程序。用户空间程序收到这样的事件后,会做相应的处理。
例如:U盘插入后,USB相关的驱动软件会动态创建用于表示该U盘的device结构(相应的也包括其中的kobject),并告知用户空间程序,为该U盘动态的创建/dev/目录下的设备节点;更进一步,可以通知其它的应用程序,将该U盘设备mount到系统中,从而动态的支持该设备。
Uevent 是通过 Netlink 套接字发送的一些特殊格式的字符串 ...
关于TLS证书
HTTPS、TLS/SSL的基本概念HTTPS(HyperText Transfer Protocol Secure)是HTTP协议的安全版。它通过加密来确保数据在客户端和服务器之间传输时不会被窃取或篡改。TLS/SSL是用于实现HTTPS的加密协议。SSL(Secure Sockets Layer)是最早的版本,后来被TLS(Transport Layer Security)取代,后者更安全和现代化。
证书与密钥的基本原理在HTTPS中,有两个核心概念:公钥加密和证书。
公钥加密:类比:想象你有一个密码箱,这个箱子有两把钥匙:公钥和私钥。公钥像是只负责锁上箱子的钥匙,任何人都可以得到一把公钥来锁上你的箱子,但只有你持有的那把私钥可以打开这个箱子。在HTTPS中,公钥用来加密数据,而私钥用来解密数据。
证书:类比:假设你去某个银行开设账户(比如申请一个公钥),银行会给你一个带有公章的证明文件,这证明你确实是你,并且你申请的账户(公钥)确实属于你。这个证明文件在HTTPS中就是证书。证书由证书颁发机构(CA,Certificate Authority)签发,它可以验证你的公钥确实属于你, ...