mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-blog.git
synced 2026-04-02 01:54:50 +00:00
updated posts
This commit is contained in:
parent
667df5f223
commit
841f570a85
3 changed files with 247 additions and 16 deletions
|
|
@ -4,7 +4,7 @@ pubDate: 2025-04-14
|
||||||
description: "使用Nonebot2和官方API,与群u一起搭了个qq机器人。"
|
description: "使用Nonebot2和官方API,与群u一起搭了个qq机器人。"
|
||||||
author: "三叶"
|
author: "三叶"
|
||||||
image:
|
image:
|
||||||
url: "de040e63935cfba0864716e0e3577515ef9a8590.jpg"
|
url: "https://files.seeusercontent.com/2026/03/25/fiG2/pasted-image-1774456117575.webp"
|
||||||
alt: "img"
|
alt: "img"
|
||||||
tags: ["Python", "Nonebot2", "QQ机器人", "教程"]
|
tags: ["Python", "Nonebot2", "QQ机器人", "教程"]
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,194 @@
|
||||||
---
|
---
|
||||||
title: 'My Second Blog Post'
|
title: "(教程)树莓派5安装sunshine实现局域网串流"
|
||||||
pubDate: 2022-07-01
|
pubDate: 2025-04-21
|
||||||
description: 'This is the first post of my new Astro blog.'
|
description: '在树莓派上安装sunshine'
|
||||||
author: 'Astro Learner'
|
author: "三叶"
|
||||||
image:
|
image:
|
||||||
url: 'https://files.seeusercontent.com/2026/03/25/0rSi/rikka-manga.jpeg'
|
url: "https://files.seeusercontent.com/2026/03/25/t2zJ/pasted-image-1774456500701.webp"
|
||||||
alt: 'The Astro logo on a dark background with a pink glow.'
|
alt: "img"
|
||||||
tags: ["astro", "blogging", "learning in public"]
|
tags: ["树莓派", "Linux", "教程"]
|
||||||
---
|
---
|
||||||
|
|
||||||
Welcome to my _new blog_ about learning Astro! Here, I will share my learning journey as I build a new website.
|
**This blog post also has an English version, click here: [(tutorial) How to Stream Via Sunshine on Your Raspberry Pi 5](https://blog.cloverta.top/archives/203)**
|
||||||
|
|
||||||
## What I've accomplished
|
## 0.在开始之前
|
||||||
|
|
||||||
1. **Installing Astro**: First, I created a new Astro project and set up my online accounts.
|
我们需要理解的是,树莓派5是arm64架构处理器,需要看准安装的sunshine版本。
|
||||||
|
|
||||||
2. **Making Pages**: I then learned how to make pages by creating new `.astro` files and placing them in the `src/pages/` folder.
|
并且Linux环境下配置sunshine会稍微有些麻烦,不过不会太麻烦(大概)
|
||||||
|
|
||||||
3. **Making Blog Posts**: This is my first blog post! I now have Astro pages and Markdown posts!
|
那我们开始吧。
|
||||||
|
|
||||||
## What's next
|
## 1.安装sunshine
|
||||||
|
|
||||||
I will finish the Astro tutorial, and then keep adding more posts. Watch this space for more to come.
|
链接:[LizardByte: Sunshine for Linux](https://github.com/LizardByte/Sunshine/releases)
|
||||||
|
|
||||||
|
树莓派使用的是基于Debian发行版的操作系统,所以我们需要找到 **sunshine-debian-bookworm-arm64.deb 。**单击下载
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
将下载好的deb安装包传入树莓派(或者直接在树莓派中下载也一样)。
|
||||||
|
|
||||||
|
进入安装包所在的目录,并在终端输入
|
||||||
|
|
||||||
|
```
|
||||||
|
dpkg -i sunshine-debian-bookworm-arm64.deb
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
dpkg -i sunshine-debian-bookworm-arm64.deb
|
||||||
|
```
|
||||||
|
|
||||||
|
以手动安装sunshine,具体包名请以你的文件名为准。
|
||||||
|
|
||||||
|
如果出现缺少依赖的问题,输入
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt-get install -f
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt-get install -f
|
||||||
|
```
|
||||||
|
|
||||||
|
安装缺失的依赖。安装好依赖后再安装一次sunshine的deb安装包。
|
||||||
|
|
||||||
|
终端输入
|
||||||
|
|
||||||
|
```
|
||||||
|
sunshine
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
sunshine
|
||||||
|
```
|
||||||
|
|
||||||
|
并回车,检查是否安装成功。
|
||||||
|
|
||||||
|
**注意:**到这一步,sunshine很有可能是没法启动的,因为缺失必要的配置。
|
||||||
|
|
||||||
|
那么紧接着下一步
|
||||||
|
|
||||||
|
## 2.配置树莓派
|
||||||
|
|
||||||
|
### ①更新系统
|
||||||
|
|
||||||
|
确保树莓派的软件是全新的,运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt update && sudo apt full-upgrade -y
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt update && sudo apt full-upgrade -y
|
||||||
|
```
|
||||||
|
|
||||||
|
这一步是必要的,因为 Wayland 的支持可能依赖于系统更新。
|
||||||
|
|
||||||
|
### ②启用Wayland支持
|
||||||
|
|
||||||
|
在较新的 Raspberry Pi OS 版本中,Wayland 已默认启用。但如果你使用sunshine时出现报错
|
||||||
|
|
||||||
|
> Error: Environment variable WAYLAND\_DISPLAY has not been defined
|
||||||
|
|
||||||
|
那么首先修改启动配置:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo nano /boot/firmware/config.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo nano /boot/firmware/config.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
打开启动配置文件,在最后面添加两行
|
||||||
|
|
||||||
|
```
|
||||||
|
dtoverlay=vc4-fkms-v3d
|
||||||
|
max_framebuffers=2
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
dtoverlay=vc4-fkms-v3d
|
||||||
|
max_framebuffers=2
|
||||||
|
```
|
||||||
|
|
||||||
|
以启动硬件加速,保存并退出后重启设备。
|
||||||
|
|
||||||
|
之后,输入
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo raspi-config
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo raspi-config
|
||||||
|
```
|
||||||
|
|
||||||
|
进入树莓派系统配置,依次选择
|
||||||
|
|
||||||
|
> 6 Advanced Options
|
||||||
|
>
|
||||||
|
> A6 Wayland
|
||||||
|
>
|
||||||
|
> W3 Labwc (这是树莓派推荐的 Wayland 合成器)
|
||||||
|
|
||||||
|
配置完成后重启。
|
||||||
|
|
||||||
|
打开VNC远程桌面(切记不要用ssh终端),在终端中输入
|
||||||
|
|
||||||
|
```
|
||||||
|
echo $XDG_SESSION_TYPE
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
echo $XDG_SESSION_TYPE
|
||||||
|
```
|
||||||
|
|
||||||
|
如果输出结果是wayland说明设定成功。
|
||||||
|
|
||||||
|
### ③启用avahi-daemon
|
||||||
|
|
||||||
|
如果出现报错
|
||||||
|
|
||||||
|
> Error: Failed to create client: Daemon not running
|
||||||
|
|
||||||
|
在终端中输入
|
||||||
|
|
||||||
|
```
|
||||||
|
systemctl enable avahi-daemon
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
systemctl enable avahi-daemon
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3.启动sunshine
|
||||||
|
|
||||||
|
非常好!现在应当完成了所有配置!
|
||||||
|
|
||||||
|
在VNC远程桌面的终端输入
|
||||||
|
|
||||||
|
```
|
||||||
|
sunshine
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
sunshine
|
||||||
|
```
|
||||||
|
|
||||||
|
以启动sunshine。
|
||||||
|
|
||||||
|
**注意:**如果你没有安装虚拟显示器,需要保证树莓派至少开启了一个桌面,无论是VNC还是连接物理显示器。最好不要通过ssh终端启动sunshine。
|
||||||
|
|
||||||
|
成功的话应该能在终端看到
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
ctrl+鼠标左键单击https://localhost:47990,通过浏览器访问sunshine的Web UI,我们就能看到熟悉的界面啦。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
之后的步骤和Windows端sunshine一样连接就可以了
|
||||||
|
|
||||||
|

|
||||||
61
src/blog/post-3.md
Normal file
61
src/blog/post-3.md
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
---
|
||||||
|
title: "[学习笔记]逐步解析Peterson算法为什么不会死等"
|
||||||
|
pubDate: 2025-06-10
|
||||||
|
description: '关于Peterson算法的学习笔记'
|
||||||
|
author: "三叶"
|
||||||
|
image:
|
||||||
|
url: "https://files.seeusercontent.com/2026/03/25/sTq9/pasted-image-1774456630694.webp"
|
||||||
|
alt: "zako2"
|
||||||
|
tags: ["peterson算法", "操作系统"]
|
||||||
|
---
|
||||||
|
|
||||||
|
在OS课程上看到一个有意思的算法——Peterson算法,那么为什么Peterson算法能满足“忙则等待”、“空闲让进”、“有限等待”这三个条件呢?
|
||||||
|
|
||||||
|
先上伪代码:
|
||||||
|
|
||||||
|
```
|
||||||
|
bool flag[2]; // 表示进入临界区意愿的数组,初始值都为false
|
||||||
|
int turn = 0; // turn表示优先让哪个进程进入临界区
|
||||||
|
|
||||||
|
// P0进程
|
||||||
|
flag[0] = true; // 首先将自己的flag设置为1,声明自己需要使用临界区
|
||||||
|
turn = 1; // 让P1优先执行,如果P1需要临界区
|
||||||
|
while (flag[1] && turn == 1); // 检查P1是否需要临界区
|
||||||
|
CRITICAL_SECTION;
|
||||||
|
flag[0] = false;
|
||||||
|
REMAINDER_SECTION;
|
||||||
|
|
||||||
|
// P1进程
|
||||||
|
flag[1] = true;
|
||||||
|
turn = 0;
|
||||||
|
while (flag[0] && turn == 0);
|
||||||
|
CRITICAL_SECTION;
|
||||||
|
flag[1] = false;
|
||||||
|
REMAINDER_SECTION;
|
||||||
|
```
|
||||||
|
|
||||||
|
让我们来分情况分析。
|
||||||
|
|
||||||
|
现在,我们假设P0和P1在并发执行,并且非常巧的是,他们一起完成了第一步,他们俩的flag都是false。
|
||||||
|
|
||||||
|
此时:
|
||||||
|
|
||||||
|
> **\[情况1\]**
|
||||||
|
> 若P0先上处理机,将turn设置为1;
|
||||||
|
> P1上处理机,将turn设置为0;
|
||||||
|
> P0上处理机,P0检查flag和turn,发现trun被改为0,不满足等待条件,P0进入临界区;
|
||||||
|
> P1上处理机,P1检查flag和turn,发现flag\[0\]为true且turn未被改变,P1等待。
|
||||||
|
> P0上处理机,且P0结束使用临界区,将flag\[1\]改为false;
|
||||||
|
> P1上处理机,发现flag\[0\]为false,结束等待,进入临界区;
|
||||||
|
>
|
||||||
|
> **\[情况2\]**
|
||||||
|
> 若P0先上处理机,将turn设置为1;
|
||||||
|
> P0继续使用处理机,发现flag\[0\]为true,turn仍然为1,满足等待条件,P0等待;
|
||||||
|
> P1上处理机,将turn改为0;
|
||||||
|
> P1继续使用处理机,发现flag\[1\]为true,turn仍然为0,满足等待条件,P1等待;
|
||||||
|
> P0上处理机,发现turn变为0,不满足等待条件,P0解除等待进入临界区;
|
||||||
|
> P1上处理机,发现等待条件仍满足,P1继续等待;
|
||||||
|
> P0上处理机,且P0结束使用处理机,将flag\[0\]改为false;
|
||||||
|
> P1上处理机,发现flag\[0\] == false, 不满足等待条件,结束等待,进入临界区;
|
||||||
|
|
||||||
|
_YES, IT WORKS ON MY MACHINE._
|
||||||
Loading…
Reference in a new issue