Lab 2: ShellC/C++

[捷稀 JCG Q30 Pro 刷机说明] 以刷入openwrt24.10为例 摘要: 本文详细介绍了捷稀JCG Q30 Pro路由器刷入OpenWrt 24.10系统的步骤。通过先刷入OpenWrt 23.05过渡固件,再升级Uboot,最后通过TFTP加载工厂镜像完成刷机。关键步骤包括解锁分区、刷写Uboot、进入恢复模式及配置网络。文章还提供了无线设置、Tailscale内网穿透等进阶命令,并附参考文档和固件下载链接。适用于有一定技术基础的玩家,需注意操作风险,严格按流程执行。 阅读详情

Java Python Lab 2: Shell

Introduction

The shell is the main command-line interface between a user and the operating system, and it is an essential part of the daily lives of computer scientists, software engineers, system administrators, and such. It makes heavy use of many OS features. In this lab, you will build a simplified version of the Unix shell called the New Yet Usable SHell, or nyush for short.

Please review the first lecture of MIT’s The Missing Semester of Your CS Education if you are not familiar with the shell.

Objectives

Through this lab, you will:

Familiarize yourself with the Linux programming environment and the shell, of course.

Learn how to write an interactive command-line program.

Learn how processes are created, destroyed, and managed.

Learn how to handle signals and I/O redirection.

Get a better understanding of the OS and system calls.

Be a better C programmer and be better prepared for your future technical job interviews. In particular, the string parsing skill that you will practice in this lab is desired in many interview questions.

Overview

The shell is essentially a command-line interpreter. It works as follows:

1. It prompts you to enter a command.

2. It interprets the command you entered.

If you entered a built-in command (e.g., cd ), then the shell runs that command.

If you entered an external program (e.g., /bin/ls ), or multiple programs connected through pipes (e.g., ls -l | less ), then the shell creates child processes, executes these programs, and waits for all these processes to either terminate or be suspended.

If you entered something wrong, then the shell prints an error message.

3. Rinse and repeat until you press Ctrl-D to close STDIN or enter the built-in command exit , at which point the shell exits.

Specifications

Your shell should follow these specifications carefully. These specifications may be slight different from the default Linux shell ( bash ) for simplicity.

The prompt

The prompt is what the shell prints before waiting for you to enter a command. In this lab, your prompt must have exactly the following format:

An opening bracket [ .

The word nyush .

A whitespace.

The basename of the current working directory.

A closing bracket ] .

A dollar sign $ .

Another whitespace.

For example, if you are in /home/abc123/2250/lab2 , then the prompt should be:

[nyush lab2]$ █

If you are in the root directory ( / ), then the prompt should be:

[nyush /]$ █

Note that the final █ character in these examples represents your cursor; you should not print that character in your shell prompt.

Keep in mind that STDOUT is line-buffered by default. Therefore, don’t forget to flush STDOUT immediately after you print the prompt. Otherwise, your program may not work correctly with the autograder.

The command

In each iteration, the user inputs a command terminated by the “enter” key (i.e., newline). A command may contain multiple programs separated by the pipe ( | ) symbol. A valid command must satisfy the following requirements:

If there are multiple programs in a command, only the first program may redirect its input (using < ), and only the last program may redirect its output (using > or >> ). If there is only one program in a command, it may redirect both input and output.

In each command, there are no more than one input redirection and one output redirection.

Built-in commands (e.g., cd ) cannot be I/O redirected or piped.

For simplicity, our test cases have the following assumptions:

Each command has no more than 1000 characters.

There is always a single space separating filenames, arguments, and the pipe and redirection symbols ( | , < , > , >> ).

There are no spaces within a filename or an argument.

For your reference, here is the grammar for valid commands (don’t worry if you can’t understand it; just look at the examples below):

[command] := ""; or := [cd] [arg]; or := [exit]; or := [fg] [arg]; or := [jobs]; or := [cmd] '<' [filename] [recursive]; or := [cmd] '<' [filename] [terminate]; or := [cmd] [recursive]; or := [cmd] [terminate] '<' [filename]; or := [cmd] [terminate]. [recursive] := '|' [cmd] [recursive]; or := '|' [cmd] [terminate]. [terminate] := ""; or := '>' [filename]; or := '>>' [filename]. [cmd] := [cmdname] [arg]* [cmdname] := A string without any space, tab, > (ASCII 62), < (ASCII 60), | (ASCII 124), * (ASCII 42), ! (ASCII 33), ` (ASCII 96), ' (ASCII 39), nor " (ASCII 34) characters. Besides, the cmdname is not cd, exit, fg, jobs. [arg] := A string without any space, tab, > (ASCII 62), < (ASCII 60), | (ASCII 124), * (ASCII 42), ! (ASCII 33), ` (ASCII 96), ' (ASCII 39), nor " (ASCII 34) characters. [filename] := A string without any space, tab, > (ASCII 62), < (ASCII 60), | (ASCII 124), * (ASCII 42), ! (ASCII 33), ` (ASCII 96), ' (ASCII 39), nor " (ASCII 34) characters.

Here are some examples of valid commands:

A blank line.

/usr/bin/ls -a -l

cat shell.c | grep main | less

cat < input.txt

cat > output.txt

cat >> output.txt

cat < input.txt > output.txt

cat < input.txt >> output.txt

cat > output.txt < input.txt

cat >> output.txt < input.txt

cat < input.txt | cat > output.txt

cat < input.txt | cat | cat >> output.txt

Here are some examples of invalid commands:

cat <

cat >

cat |

| cat

cat << file.txt

cat < file.txt < file2.txt

cat < file.txt file2.txt

cat > file.txt > file2.txt

cat > file.txt >> file2.txt

cat > file.txt file2.txt

cat > file.txt | cat

cat | cat < file.txt

cd / > file.txt

If there is any error in parsing the command, then your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid command

Note that there should be a newline at the end of the error message. For example:

[nyush lab2]$ cat <

Error: invalid command

[nyush lab2]$ █

(Again, the final █ character represents your cursor.)

Locating programs

You can specify a program by either an absolute path, a relative path, or base name only.

1. An absolute path begins with a slash ( / ). If the user specifies an absolute path, then your shell must run the program at that location.

2. A relative path contains, but not begins with, a slash ( / ). If the user specifies a relative path, then your shell should locate the program by following the path from the current working directory. For example, dir1/dir2/program is equivalent to ./dir1/dir2/program .

3. Otherwise, if the user specifies only the base name without any slash ( / ), then your shell must search for the program under /usr/bin . For example, when the user types ls , then your shell should try /usr/bin/ls . If that fails, it is an error. In this case, your shell should not search the current working directory. For example, suppose there is a program named hello in the current working directory. Entering hello should result in an error, whereas ./hello runs the program.

In any case, if the program cannot be located, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid program

Process termination and suspension

After creating the processes, your shell must wait until all the processes have stopped running—either terminated or suspended. Then, your shell should prompt the user for the next command.

Your shell must not leave any zombies in the system when it is ready to read the next command from the user.

Signal handling

If a user presses Ctrl-C or Ctrl-Z , they don’t expect to terminate or suspend the shell. Therefore, your shell should ignore the following signals: SIGINT , SIGQUIT , and SIGTSTP . All other signals not listed here should keep the default signal handlers.

Note that only the shell itself, not the child processes created by the shell, should ignore these signals. For example,

[nyush lab2]$ cat

^C

[nyush lab2]$ █

Here, the signal SIGINT generated by Ctrl-C terminates only the process cat , not the shell itself.

As a side note, if your shell ever hangs and you would like to kill the shell, you can still send it the SIGTERM or SIGKILL signal. To do so, you can connect to the running Docker container from another terminal window using:

docker exec -it 2250 bash

…and then kill your shell using:

[root@... 2250]# killall nyush

I/O redirection

Sometimes, a user would read the input to a program from a file rather than the keyboard, or send the output of a program to a file rather than the screen. Your shell should be able to redirect the standard input ( STDIN ) and the standard output ( STDOUT ). For simplicity, you are not required to redirect the standard error ( STDERR ).

Input redirection

Input redirection is achieved by a < symbol followed by a filename. For example:

[nyush lab2]$ cat < input.txt

If the file does not exist, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid file

Output redirection

Output redirection is achieved by > or >> followed by a filename. For example:

[nyush lab2]$ ls -l > output.txt

[nyush lab2]$ ls -l >> output.txt

If the file does not exist, a new file should be created. If the file already exists, redirecting with > should overwrite the file (after truncating it), whereas redirecting with >> should append to the existing file.

Pipe

A pipe ( | ) connects the standard output of the first program to the standard input of the second program. For example:

[nyush lab2]$ cat shell.c | wc -l

The user may invoke n programs chained through (n - 1) pipes. Each pipe connects the output of the program immediately before the pipe to the input of the program immediately after the pipe. For example:

[nyush lab2]$ cat shell.c | grep main | less

Here, the output of cat shell.c is the input of grep main , and the output of grep main is the input of less .

Built-in commands

Every shell has a few built-in commands. When the user issues a command, the shell should first check if it is a built-in command. If so, it should not be executed like other programs.

In this lab, you will implement four built-in commands: cd , jobs , fg , and exit .

cd <dir>

This command changes the current working directory of the shell. It takes exactly one argument: the directory, which may be an absolute or relative path. For example:

[nyush lab2]$ cd /usr/local

[nyush local]$ cd bin

[nyush bin]$ █

If cd is called with 0 or 2+ arguments, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid command

If the directory does not exist, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid directory

jobs

This command prints a list of currently suspended jobs to STDOUT , one job per line. Each line has the following format: [index] command . For example:

[nyush lab2]$ jobs

[1] ./hello

[2] /usr/bin/top -c

[3] cat > output.txt

[nyush lab2]$ █

(If there are no currently suspended jobs, this command should print nothing.)

A job is the whole command, including any arguments and I/O redirections. A job may be suspended by Ctrl-Z , the SIGTSTP signal, or the SIGSTOP signal. This list is sorted by the time each job is suspended (oldest first), and the index starts from 1.

Note for Windows users

If you’re using recent versions of Windows, you might need to enable Legacy Console mode in order for Ctrl-Z to be properly handled by PowerShell.

For simplicity, we have the following assumptions:

There are no more than 100 suspended jobs at one time.

There are no pipes in any suspended jobs.

The only way to resume a suspended job is by using the fg command (see below). We will not try to resume or terminate a suspended job by other means. We will not try to press Ctrl-C or Ctrl-D while there are suspended jobs.

You don’t need to worry about “process groups.” (If you don’t know what process groups are, don’t worry.)

The jobs command takes no arguments. If it is called with any arguments, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid command

fg <index>

This command resumes a job in the foreground. It takes exactly one argument: the job index, which is the number inside the bracket printed by the jobs command. For example:

[nyush lab2]$ jobs

[1] ./hello

[2] /usr/bin/top -c

[3] cat > output.txt

[nyush lab2]$ fg 2

The last command would resume /usr/bin/top -c in the foreground. Note that the job index of cat > output.txt would become 2 as a result. Should the job /usr/bin/top -c be suspended again, it would be inserted to the end of the job list:

[nyush lab2]$ jobs

[1] ./hello

[2] cat > output.txt

[3] /usr/bin/top -c

[nyush lab2]$ █

If fg is called with 0 or 2+ arguments, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid command

If the job index does not exist in the list of currently suspended jobs, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid job

exit

This command terminates your shell. However, if there are currently suspended jobs, your shell should not terminate. Instead, it should print the following error message to STDERR and prompt for the next command.

Error: there are suspended jobs

The exit command takes no arguments. If it is called with any arguments, your shell should print the following error message to STDERR and prompt for the next command.

Error: invalid command

Note that if the STDIN of your shell is closed (e.g., by pressing Ctrl-D at the prompt), your shell should terminate regardless of whether there are suspended jobs.

Compilation

We will grade your submission in an x86_64 Rocky Linux 8 container on Gradescope. We will compile your program using gcc 12.1.1 with the C17 standard and GNU extensions.

You must provide a Makefile , and by running make , it should generate an executable file named nyush in the current working directory. (Refer to Lab 1 for an example of the Makefile .)

Your program must not call the system() function or execute /bin/sh. Otherwise, what is the whole point of this lab?

Evaluation

Beat up your own code extensively. Better yet, eat your own dog food. I would happily use nyush as my main shell (at least for the duration of this lab), so why wouldn’t you?

We are providing a sample autograder with a few test cases. Please extract them inside the Docker container and follow the instructions in the README file. (Refer to Lab 1 for how to extract a .tar.xz file.)

Note that these test cases are not exhaustive. The test cases on Gradescope are different from the ones provided and will not be disclosed. Do not try to hack or exploit the autograder.

Submission

You must submit a .zip archive containing all files needed to compile nyush in the root of the archive. You can create the archive file with the following command in the Docker container:

$ zip nyush.zip Makefile *.h *.c

(Omit *.h if you don’t have header files.)

Note that other file formats (e.g., rar ) will not be accepted.

You need to upload the .zip archive to Gradescope. If you need to acknowledge any influences per our academic integrity policy, write them as comments in your source code.

Rubric

The total of this lab is 100 points, mapped to 15% of your final grade of this course.

Compile successfully and can print the correct prompt. (40 points)

Process creation and termination. (20 points)

Simple built-in commands ( cd and exit ) and error handling. (10 points)

Input and output redirection. (10 points)

Pipes. (10 points)

Handling suspended jobs ( jobs and fg ). (10 points)

You will get 0 points for this lab if you call the system() function or execute /bin/sh.

Please make sure that your shell prompt and all error messages are exactly as specified in this document. Any discrepancy may lead to point deductions.

Tips

Don’t procrastinate! Don’t procrastinate!! Don’t procrastinate!!!

This lab is significantly more challenging than Lab 1 and requires significant programming effort. Therefore, start as early as possible! Don’t wait until the last week.

How to get started?

Please review our academic integrity policy carefully before you start.

This lab requires you to write a complete system from scratch, so it may be daunting at first. Remember to get the basic functionality working first, and build up your shell step-by-step.

Here is how I would tackle this lab:

Milestone 1. Write a simple program that prints the prompt and flushes STDOUT . You may use the getcwd() system call to get the current working directory.

Milestone 2. Write a loop that repeatedly prints the prompt and gets the user input. You may use the getline() library function to obtain user input.

Milestone 3. Extend Milestone 2 to be able to run a simple program, such as ls . At this point, what you’ve written is already a shell! Conceptually, it might look like:

while (true) { // print prompt // read command pid = fork(); if (pid < 0 0 0) { // fork failed (this shouldn't happen) } else if (pid == 000) { // child (new process) execv(...); // or another variant // exec failed } else { // parent waitpid(-111, ...); } }

Milestone 4. Extend Milestone 3 to run a program with arguments, such as ls -l .

Milestone 5. Handle simple built-in commands ( cd and exit ). You may use the chdir() system call to change the working directory.

Milestone 6. Handle output redirection, such as cat > output.txt .

Milestone 7. Handle input redirection, such as cat < input.txt .

Milestone 8. Run two programs with one pipe, such as cat | cat . The example code in man 2 pipe is very helpful.

Milestone 9. Handle multiple pipes, such as cat | cat | cat .

Milestone 10. Handle suspended jobs and related built-in commands ( jobs and fg ). Read man waitpid to see how to wait for a stopped child.

Some students may find handling suspended jobs easier than implementing pipes, so feel free to rearrange these milestones as you see fit.

Keep versions of your code! Use git or similar tools, but don’t make your repository public.

Useful system calls

Your shell will make many system calls. Here are a few that you may find useful.

Process management: access() , fork() , execv() (or other variants), waitpid() .

I/O redirection and pipes: dup2() , creat() , open() , close() , pipe() .

Signal handling: signal() .

Built-in commands: chdir() , getcwd() , kill() .

You might not need to use all of them, and you are free to use other system calls not mentioned above.

Check the return values (and possibly, errno ) of all system calls and library function calls from the very beginning of your work! This will often catch errors early, and it is a good programming practice.

Reading man pages

Man pages are of vital importance for programmers working on Linux and such. It’s a treasure trove of information.

Man pages are divided into sections. Please see man man for the description of each section. In particular, Section 2 contains system calls. You will need to look them up a lot in this lab.

Sometimes, you need to specify the section number explicitly. For example, man kill shows the kill command in Section 1 by default. If you need to look up the kill() system call, you need to invoke man 2 kill .

Parsing the command line

You might find writing the command parser troublesome. Don’t be frustrated. You are not alone. However, it is an essential skill for any programmer, and it often appears in software engineer interviews. Once you get through it, you will never be afraid of it again.

I personally find the strtok_r() function extremely helpful. You don’t have to use it, but why not give it a try?

In gdb, how to debug the child process after fork()?

By default, when a program forks, gdb will continue to debug the parent process, and the child process will run unimpeded.

If you want to follow the child process instead of the parent process, use the command set follow-fork-mode child .

If you want to debug both the parent and child processes, use the command set detach-on-fork off . Then, you can use info inferiors to show all processes and use inferior to switch to another process.

I’m still confused about pipes. Any more hints?

If you can already support I/O redirection for a single process, adding support for pipes shouldn’t be too difficult since a pipe is just two I/O redirections. Start by reading the example code in man 3 pipe and writing a simple program to see how pipe works.

Here are some additional hints:

Make sure a single pipe works before trying multiple pipes.

To support a single pipe, the parent (shell) process should create the pipe and fork two children. The first child redirects its output to the write end of the pipe, and the second child redirects its input from the read end of the pipe. In other words, instead of opening a file for redirection, use the file descriptors returned by pipe() .

Both children should run concurrently. The parent (shell) process should wait for both children. In other words, a child shouldn’t wait for another child.

Make sure to close all unused file descriptors, otherwise your child process may not terminate. In the above case, the parent holds two ends of the pipe, and after fork() , each child holds two ends of the pipe. So altogether you need to close six file descriptors. The parent should close them before calling waitpid() , and the child should close them before calling execv() .

Supporting multiple pipes is similar. For N processes, your shell should create N-1 pipes and fork N children. You can either write a loop or use recursion to do that.

I’m still confused about suspended jobs. Any more hints?

To support suspended jobs, your shell should call waitpid() with the WUNTRACED option and check the returned status with WIFSTOPPED() . If that’s true, add the job to the list of suspended jobs.

To resume a job, just kill() it with SIGCONT .

I don’t want to reënter gdb when I press Ctrl-Z. Is it possible?

You can always use c to continue the program, or you can use the command handle SIGTSTP nostop noprint to prevent gdb from handling the signal.

I hate the command line! Can I debug in VS Code?

First, I recommend leaving your comfort zone and embracing the command line. For many of you, it will be an essential skill in your career.

However, if you can’t live without a GUI, you can follow these steps to attach VS Code to a running container:

1. Install the Dev Containers extension in VS Code.

2. Start the container in your OS as usual using the docker run command.

3. In VS Code, press Ctrl-Shift-P (Windows) or ⇧⌘P (Mac) and select Dev Containers: Attach to Running Container... .

4. Select cs202 from the pop-up.

5. Now, you have connected your VS Code to the container. Remember to install useful extensions inside the container, such as the C/C++ extension, since it is a remote environment.

6. You can configure gdb in VS Code.

7. To switch between processes in VS Code, add these lines to launch.json         

YOLOv8改进 | 融合篇,YOLOv8主干改进融合网络之MobileNetV3+CA注意机制,助力涨点 MobileNetV3通过结合硬件感知网络架构搜索(NAS)和NetAdapt算法,通过新颖的架构改进进一步提升了性能。YOLOv8中的主干网络替换成MobileNetV3+引入CA注意机制 阅读详情

相关推荐

深入解析 ReDoc:从零构建高性能 API 文档的终极指南

ReDoc 是一个强大的开源工具,用于将 OpenAPI 规范转换为高质量、响应式的 API 文档。本文详细介绍了如何使用 ReDoc 构建和自定义 API 文档,包括如何编写支持 OpenAPI 的 API 注解、配置 HTML 页面以加载文档,以及如何利用 ReDoc 的高级功能进行定制。通过实例代码,您将学会如何灵活地展示 API 文档,提升用户体验。无论是初学者还是经验丰富的开发者,都能从本文中获得实用的技巧与方案,帮助快速搭建符合需求的 API 文档界面。

楠搏万的博客 4639

Linux中使用C++模拟Shell(东南大学 OS Lab 2)

本文在Deepin20.09中编写了一个C++程序,以此来模拟Shell的功能。

Huonzy的博客 1762

PL端:HDMI 输出实验

开发板没有HDMI编码芯片,是将FPGA的3.3差分IO直接连接到HDMI连接器,FPGA 完成 24 位 RGB 编码输出TMDS 差分信号。1、学会使用第三点IP核,首先是添加,后面的使用和自带IP核操作一致。2、主要还是在梳理vivado使用流程。

qq_43441284的博客 4289

深挖C++:类和对象(中)

(先进后出)

xys_678的博客 261

告别切换烦恼!用Parallels Desktop的Host-Only网卡,在macOS上直接访问虚拟机里的公司内网

本文详细介绍了如何在macOS上使用Parallels Desktop的Host-Only网卡直接访问虚拟机内的公司内网,告别频繁切换操作系统的烦恼。通过配置Host-Only网络模式,实现主机与虚拟机的安全高效通信,特别适合需要频繁访问内网资源的IT从业者。文章包含分步指南、自动化脚本和常见问题解决方案,帮助用户优化工作流程。

weixin_28739079的博客 364

论文阅读 Quantum Convolutional neural network

在传统的局域序参量(如磁化强度 ⟨Xi⟩)无法有效区分某些拓扑相(如 Haldane 相)时,字符串序参量(SOP)提供了一种方法来识别这些相。字符串序参量的定义通常涉及多个远离的站点之间的长程关联,通常具有如下形式:Zi,Xk,Zj是泡利矩阵(Pauli operators)。指数项 eiπ∑k=ijXk表示一个相位因子。这意味着我们要计算两个远离站点 i,j 的Z 分量的关联,同时考虑它们之间的X 作用。这个非局域的字符串序参量可以用来检测对称保护拓扑(SPT)相。

m0_54373077的博客 2006

跟我学c++中级篇—类型定义的方式

本文系统阐述了编程中类型定义的重要性及c++中的实现方式。重点对比了宏定义、typedef与modern using三种机制,指出using在可读性、灵活性和模板支持上的优势,推荐优先使用。同时提醒开发者注意别名滥用、类型歧义、错误信息冗长等问题,强调统一规范与合理设计。最终结论:在现代c++开发中,应以using为主,兼顾简洁性与可维护性,避免陷入命名混乱与编译困境。

fpcc的专栏 400

ESP32 DMX512与RDM协议栈开发指南

DMX512-A是专业灯光控制领域广泛采用的串行通信标准,基于RS-485物理层实现确定性单向数据传输;RDM(Remote Device Management)则在其基础上扩展双向、可寻址、可配置的智能管理能力,满足现代舞台设备远程固件升级、自动发现与参数配置需求。二者共用同一总线但时序与帧结构严格隔离,对硬件定时精度、中断响应延迟及电气隔离提出极高要求。在嵌入式实践中,ESP32凭借Wi-Fi/蓝牙连接能力与丰富外设资源,成为构建低成本智能DMX节点的理想平台。esp_dmx协议栈正是面向该场景的高性能

weixin_34945060的博客 316

【C/C++ 第一次跨越(下):移动语义与 noexcept——不改变行为的性能修复】

本文详解C++11移动语义在迁移至现代C++时的性能优化策略,强调“不改变行为”的前提下通过合理使用移动语义消除深拷贝开销。重点解析移动操作生成规则:析构函数、拷贝函数或const/引用成员会抑制移动构造;noexcept影响std::vector是否选择移动而非回退拷贝。提出“Rule of Zero”原则——用RAII封装资源,避免手动实现特殊成员函数,确保移动语义被正确调用,实现零开销移动与内存安全。

一起学习进步! 298

【配环境】ubuntu18.04 3080ti显卡+cuda+cudnn+torch

1.打开系统设置中的software & updates点击 System Settings,选择 Additional Drivers 标签,下面会列出当前显卡可用的驱动版本。 注意:3080ti建议不要安装最新版本驱动 点击Apply Changes即可安装; 注意:3080ti只能装cuda11.x 修改软连接修改系统使用的cuda 卸载老版本cuda 重新查询看是否卸载成功 显卡驱动及CUDA Toolkit最高对应版本 查询驱动版本............

sinat_41670685的博客 3914

大模型LLM部署方式

建议根据实际需求选择方案,企业级服务优先考虑vLLM或TGI,个人用户可尝试Ollama或Hugging Face本地加载。若需完整代码示例,可参考网页2的VLLM实战或网页5的TGI部署案例。:高并发、低延迟的API服务,需分布式推理支持。:快速创建可分享的Web应用。:个人开发、快速原型验证。

u010249118的博客 518

【C++】C++17的主要特性

C++17引入多项重要特性:结构化绑定简化多值返回与遍历;inline变量解决头文件中变量定义的ODR问题,支持类内初始化;if/switch初始化语句允许在条件中声明变量,提升代码简洁性;属性语法(如[[nodiscard]]、[[deprecated]])增强代码可读性与安全性;求值顺序明确化,提高程序可预测性。这些改进显著提升了代码的简洁性、安全性和可维护性。

记录我一步步的学习历程,期待无限进步,向星举目! 348

基于YOLOv8的野生菌菇检测、识别与分类系统

YOLOv8是YOLO系列模型的最新版本,继承了YOLO系列高效、精确的特点。YOLOv8采用了新的网络架构,并优化了推理速度和检测精度。与传统的目标检测算法(如Faster R-CNN)不同,YOLO模型通过一次前向传播同时完成目标定位与分类,因而具有非常高的计算效率。

YOLO 1284

【C++碎片化知识补充】C++ 里 int 也算对象?聊聊对象和变量的边界

盯着sessionId不就是个变量吗?变量凭什么能调用函数?后来才反应过来——它当然是对象。是我把对象这个词理解窄了。

2501_93351213的博客 350

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

【C++ 基础入门】C++11新特性(下):可变参数模板、lambda 表达式与包装器

C++11高阶特性(可变参数模板与参数包展开、emplace_back、lambda表达式与捕获列表、仿函数、std::function包装器)

2601_96587588的博客 268

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

#SQLite 数据库笔记一:(概念 / 终端指令 / SQL 语句 / C 编程 / 回调函数)

数据库 = 数据的仓库,假设数据是海量。能力说明存储数据持久化保存,程序退出数据还在统计数据、分组、排序数据管理增、删、改、查(CRUD)嵌入式设备上也会用数据库(单片机网关、路由器、工业 HMI 都常见),因为 sqlite 体积小、无需服务进程、单文件即可。数据库 = 库 > 表 > 记录(行) > 字段(列)sqlite3 = 开源、C 写的、单文件、免安装、最多 2T 的嵌入式关系型数据库。

lwq20051110的博客 260

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

1-10 PostgreSQL中多表连接全解:inner/left/right/full/cross join

本文基于 PostgreSQL 15+ 完整拆解 5 种主流连接:内连接、左连接、右连接、全连接、笛卡尔连接。结合可落地的测试数据,演示每种连接的执行逻辑、返回结果,重点剖析 NULL 值对 JOIN 匹配的核心影响,彻底解决多表连接数据丢失、匹配异常、结果错乱的问题。

zhangjw34的专栏 145

蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级 备考:莫队算法离线区间查询详解

备赛进行时:第十八届蓝桥杯软件赛报名已于 2026-10-08 10:00 开启、12-18 14:00 截止,省赛定在 2027-04-10(C/C++·Python 程序设计 9:00–13:00);中国电子学会 2026 年 12 月软件编程(C/C++ 一级至十级、Python 一级至六级)考级报名 9/23–12/2 16:00、统考 12-12;全国青少年信息素养大赛 2026—2027 赛季算法应用主题赛也已进入复盘练兵窗口。

IT_Scratch的博客 184

c++ explicit关键字详解

explicit。

拒绝AI文,努力在AI时代写出感动人心的好文章 169

825 mW 顶上 212 °C:ASM491S 的 105 °C/W、250 mA 短路电流与热关断

25 °C 环境里结温 34.1 °C,125 °C 环境里结温 134.1 °C——后者已经离 150 °C 只有 16 °C 了,但还在范围内。换个角度看同一件事:从 25 °C 和从 125 °C 起算,温升都是 86.6 °C,但一个到 111.6 °C(还在范围内),一个到 211.6 °C(远远超限)。这个算例里 20 °C/W 是我假设的,实际值取决于机壳材料、密封程度、有没有风扇,跨度可以从 5 °C/W 到 50 °C/W 以上。外面 50 °C 的机箱,盒内就是 63.9 °C。

ANSILIC的博客 402

CMake从入门到精通:多模块与配置文件实战

cmake实践领域推荐做法避免做法构建目录始终使用 out-of-source build (在源目录直接运行 cmake,导致生成大量垃圾文件源文件列表显式列出源文件过度依赖,导致新增文件后需重新运行 cmake变量作用域使用target_前缀命令 (如使用全局,污染所有目标的作用域库链接明确指定PUBLICPRIVATEINTERFACE默认不指定,导致依赖传递关系混乱C++ 标准使用或硬编码-std=c++11到通过上述模块化结构、自定义.cmake。

Tomhex的博客 172

【C】Lesson3顺序表 链表

顺序表。

2503_92107148的博客 29

C++课后习题训练记录Day206

在一个城市,蓝泽是一个著名的侦探,他手上有一份秘密情报——一串由数字组成的密码。密码的解析从零开始,即第一个元素是 a0​,第二个元素是 a1​,依此类推。然而,这个密码有个特殊的设定,只有当偶数位置(a0​,a2​,a4​,......)的元素之和达到最大值,才能解开密码的真正含义。在一行上输出一个整数 —— 在反转至多一个子数组(连续子段)后,偶数位置上的元素的最大可能总和。第二行包含 n 个整数 a0​,a1​,...,an−1​。对此代码进行检验,检验后无报错,运行此代码,运行结果正确。

zmzb0103的博客 228

Windows 11 26H2 存储空间清理指南:C 盘瘦身、存储感知与深度清理实操

Windows 11 26H2 C 盘满了怎么清理?本文按四层顺序给出存储感知与清理建议配置、磁盘清理系统级勾选项、WinSxS 与保留存储的 DISM 精简命令,以及文件夹位置重定向和 C 盘无损扩容方法,全程用系统自带工具。

the3clipse的博客 310

【容斥原理计数】题解:P9489 ZHY的表示法_容斥原理_计数问题_前缀和问题转化_算法竞赛C++

给定 $ n $ 个正整数,求区间 $[l,r]$ 中有多少正整数 $ x $ 可表示为 $ \sum \lfloor \frac{y}{x_i} \rfloor $。通过二分确定最大 $ y $,转化为求 $ 1 \sim H $ 中是某些 $ x_i $ 倍数的数的个数,利用容斥原理与 DFS 枚举子集计算,结合 LCM 预判剪枝及去重优化,时间复杂度 $ O(2^n \log V) $,可高效处理 $ r \le 10^9 $ 的数据。

YLCHUP的博客 108

C语言结构体内存对齐与动态内存

int定义整数、float定义小数,而struct定义的是一种复合类型,成员类型可以完全不同:int id;/* 4 字节 *//* 20 字节 *//* 4 字节 */char sex;/* 1 字节 */关键字struct不能省是完整类型名结尾必须有分号——这个分号少了,编译器会报一堆莫名其妙的错结构体名可以随便起(studentaa张三都行),但要有意义这一步初学者最容易混:struct student { /* 只是"画图纸",此时不占内存 */int id;​。

2401_89953644的博客 183
上一篇: FIN 301 Midterm 1 Review QuestionsStatistics
下一篇: ENED 1100 – ACTIVITIES AND HOMEWORK W7D1: LABVIEW REPETITIONPython
wolfminy
博客等级 码龄2年 270粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值