编译linux

14 篇文章 0 订阅
这篇博客介绍了如何在Linux环境下编译安装内核,提供了详细的步骤和资源链接。作者通过实例展示了进程管理,包括查看进程的`ps`命令和使用`prctl`设置进程名称。此外,还探讨了管道的概念,以`ls | grep`为例解释其工作原理。最后,给出了一个简单的C程序示例,演示了进程创建和命名。
摘要由CSDN通过智能技术生成

编译安装一个linux

Linux内核下载

The Linux Kernel Archives

https://zhuanlan.zhihu.com/p/424240082

从kernel.org安装源代码到/user/src/linux目录下面

我下载了linux-5.15.62,解压缩预计15分钟。。。

代码目录:https://zhuanlan.zhihu.com/p/375238002

官方文档:The Linux Kernel documentation — The Linux Kernel documentation

Linux内核源码分析:基于最新的Linux 4.0内核(学习路线总结)_后端_Linux服务器开发_InfoQ写作社区

1. 学习站点:
https://elixir.bootlin.com/linux/0.12/source/ 在线源码阅读
Linux_Kernel_Newbies - Linux Kernel Newbies 新手引导
What every computer science major should know (might.net)

2.参考书籍:
Linux Kernel Development
Understanding the Linux Kernel

进程管理

linux的进程再/proc文件内,这个文件不是在硬盘上面,是在内存中。

查看进程命令

ps

qemu

https://www.iteye.com/blog/lobin-2047130

wang@ubuntu:~/Desktop/c$ tree
.
├── main
├── main.c
├── test
└── test.c

main.c
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include <sys/prctl.h>
int main()
{

	printf("fork...\n");
	prctl(PR_SET_NAME, "mymain", NULL, NULL, NULL);
	int i =0;
	if(fork()==0)
	{
		execlp("/home/wang/Desktop/c/test",NULL);
		printf("creat test ...\n");
	}
	

	while(1)
	{
		printf("main gitpid() = %d\n",getpid());
		sleep(1);
	}
	return 0;
}

test.c

#include<stdio.h>
#include<unistd.h>
#include <sys/prctl.h>

int main()
{
	int i=0;
	prctl(PR_SET_NAME, "mytest", NULL, NULL, NULL);
	while(1){
		printf("test.c pid = %d\n",getpid());
		sleep(1);
	}


	return 0;
}

管道

管道运算符 |

ls | grep :把第一个程序运行的结果作为第二个程序的输入

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值