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

js做网站统计百度推广seo效果怎么样

js做网站统计,百度推广seo效果怎么样,wordpress限制用户下载次数,佛山网站开发大家好,我是苏貝,本篇博客带大家了解Linux进程(9)进程控制1,如果你觉得我写的还不错的话,可以给我一个赞👍吗,感谢❤️ 目录 1 fork函数2 进程终止(A)终止是…

大家好,我是苏貝,本篇博客带大家了解Linux进程(9)进程控制1,如果你觉得我写的还不错的话,可以给我一个赞👍吗,感谢❤️
在这里插入图片描述


目录

  • 1 fork函数
  • 2 进程终止
    • (A)终止是在做什么?
    • (B)退出码
    • (C)进程退出的3种情况
    • (D) 如何终止进程
      • 1. main函数return表示进程终止(非main函数return表示函数结束)
      • 2. 代码调用exit函数
      • 3. _exit函数 ---系统调用

1 fork函数

在这里插入图片描述

如果fork出错,那就不创建子进程,给父进程返回-1

为什么给父进程返回的是子进程的pid?
为了让父进程方便对子进程进行标识,进而进行管理

如何理解进程具有独立性?
进程=内核的相关管理数据结构(task_struct+mm_struct+页表)+代码和数据。对于不是父子进程的多个进程,上面的5个都不同,自然具有独立性。对于父子进程,task_struct自然不同;子进程的mm_struct和页表都是拷贝父进程的,但每个进程都有自己独立的mm_struct和页表,所以也互不影响;代码是共享的,也是只读的,所以父子进程互不影响;对于数据:父子不写入时,数据也是共享的;如果其中一个进程想要对数据进行写入,会发生写时拷贝,因此父子进程也互不影响。所以,父子进程也具有独立性,所以进程具有独立性

2 进程终止

(A)终止是在做什么?

  1. 释放曾经的代码和数据所占据的空间
  2. 释放内核数据结构(mm_struct和页表)的空间,但是task_struct会维持一段时间,变成Z状态(僵尸状态),进程要维持自己的退出信息,退出信息位于task_struct中,未来让父进程进行读取

(B)退出码

退出码是在进程执行结束后,系统返回给使用者的一个数值,用以表示进程的执行状态。main函数最后的return后面的数字是退出码。
在这里插入图片描述

所以上面代码的退出码就是0,那如何查看退出码呢?用echo $?命令,Linux提供了一个专门的变量?来保存父进程获取的,最近一个子进程的退出码
在这里插入图片描述

修改.c文件
在这里插入图片描述

退出码应该为100

在这里插入图片描述

上面说,?是保存父进程获取的,最近一个子进程的退出码,那为什么第二次?的值是0呢?
在这里插入图片描述

第二次的?是保存第一个echo $?的退出码,虽然echo不是bash的子进程,但也是由bash执行的,所以照样可能会影响退出码。因为第一个echo $?运行成功,所以退出码为0

退出码有什么用呢?
告诉关心方(一般为父进程),进程把任务完成的怎么样了。
如果退出码为0,表示程序运行成功;为!0,表示失败。不同的!0值,一方面表示失败,一方面也表示失败的原因,即有对应的错误描述

现在我们来看看退出码对应的错误描述

先看strerror函数,作用:返回错误码的字符串描述。参数是错误码
在这里插入图片描述

修改.c文件
在这里插入图片描述
在这里插入图片描述

0表示成功,1表示操作不被允许,2表示没有该文件或目录……

关于退出码,我们可以选择使用系统默认的,也可以使用我们自定义的。
我们来试试用自定义的退出码

修改.c文件
在这里插入图片描述
在这里插入图片描述

但我们发现,如果result==-1,我们不能确定是y == 0还是y! =0,x/y == -1

修改.c文件
在这里插入图片描述

如果result==-1,错误码== 1,那么说明y== 0。如果result==-1,错误码== 0,说明x/y ==-1
在这里插入图片描述

因此,退出码可以确定代码跑完,结果是否正确。所以,你是否感觉到以前写的代码都不是很规范呢?有没有正确使用退出码呢?

(C)进程退出的3种情况

  1. 代码跑完,结果正确
  2. 代码跑完,结果不正确
  3. 代码执行时,出现异常,提前退出了

前2个可以根据退出码判断,就不再赘述了。现在我来看看第3种情况:代码执行时,出现异常,提前退出了

我们之前在写代码的时候,一定遇到过程序崩溃的情况吧。崩溃是语言层面说的,在系统层面,是因为操作系统发现你的进程做了不该做的事情,所以将进程杀掉了。

所以进程出异常的本质是因为进程收到了OS发给进程的信号

现在我们来用野指针让进程出异常
在这里插入图片描述
在这里插入图片描述

出现异常,并报错:Segmentation fault,表示段错误。OS提前终止进程

上面说,进程出异常的本质是因为进程收到了OS发给进程的信号,现在让我们来感受一下

修改.c文件
在这里插入图片描述

该进程正常来讲的话,是不会有异常的

再使用kill的11号信号
在这里插入图片描述
在这里插入图片描述

此时尽管代码没有错误,但是由于进程收到了系统的信号,所以判断是 Segmentation fault,段错误标识,进程提前终止了。因此我们也可以感受到进程出异常是因为进程收到了OS发给进程的信号

因此,我们可以通过看进程退出的时候,退出信号是什么,来判断我的进程为什么异常了。如果进程没有异常,代码跑完了,那退出信号为0
请问,如果进程出现异常,提前退出了,那还需要知道退出码吗?不用了,进程出现异常,退出码就没有意义了

如何确定程序退出是3种情况的哪一种呢?

  1. 先确认是否异常
  2. 不是异常,就是代码跑完了,看退出码判断结果是否正确

结论:衡量一个进程退出,我们只需要知道2个数字:退出码和退出信号
退出码为0,退出信号为0,代码跑完了,结果正确
退出码为!0,退出信号为0,代码跑完了,结果不正确
退出码为0,退出信号为!0,进程出现异常
退出码为!0,退出信号为!0,进程出现异常

一个进程结束,系统会释放它对应的代码和数据的空间,释放内核数据结构(mm_struct和页表),但是task_struct会维持一段时间,变成Z状态(僵尸状态),系统会将进程的退出码和退出信号写入进程的task_struct中,等待父进程进行读取

(D) 如何终止进程

1. main函数return表示进程终止(非main函数return表示函数结束)

2. 代码调用exit函数

先了解exit函数,作用:让一个正常的进程终止,参数是退出码
在这里插入图片描述

修改.c文件
在这里插入图片描述

退出码:123
在这里插入图片描述

上面说,main函数return表示进程终止(非main函数return表示函数结束)。那如果是在非main函数中调用exit函数,是表示函数结束还是进程终止呢?

修改.c文件
在这里插入图片描述

运行程序,先进入Div函数,因为100!=0,所以执行代码exit(13)
在这里插入图片描述

进程并没有打印main函数的printf函数里的内容,所以在非main函数中调用exit函数,是进程终止。
所以在代码的任意位置调用exit函数,都表示进程退出

3. _exit函数 —系统调用

先了解一下_exit,作用:终止进程,参数也是退出码
在这里插入图片描述

修改.c文件
在这里插入图片描述
在这里插入图片描述

进程也没有打印main函数的printf函数里的内容,所以在代码的任意位置调用_exit函数,都表示进程退出

那exit函数和_exit函数有什么不同吗?

修改.c文件
在这里插入图片描述
在这里插入图片描述

结果:先等待2秒,再打印出”hello world”,这说明exit函数会冲刷缓冲区

修改.c文件
在这里插入图片描述
在这里插入图片描述

结果:等待2秒后,不会打印”hello world” ,这说明_exit函数不会冲刷缓冲区

exit vs _exit:exit函数会冲刷缓冲区,而_exit不会。
这说明,我们所说的缓冲区不在OS内,即不是内核缓冲区。

理由:

  1. exit底层调用的就是_exit,因为杀掉进程本质就是释放进程对应的代码和数据,释放进程的除pcb以外的其它内核数据结构。总之,是对进程做管理的一种方式。但用户没有权利对操作系统内的字段做任何访问,包括终止一个进程。因此,exit底层一定会调用_exit系统调用

在这里插入图片描述

如果缓冲区在操作系统,exit能冲刷缓冲区,那么_exit也能,因为exit底层调用的就是_exit。但是_exit不能,因此缓冲区不在OS内,即不是内核缓冲区,而在_exit之上,exit先冲刷缓冲区,再调用_exit


好了,那么本篇博客就到此结束了,如果你觉得本篇博客对你有些帮助,可以给个大大的赞👍吗,感谢看到这里,我们下篇博客见❤️


文章转载自:
http://dinncorotund.tqpr.cn
http://dinncocardiganshire.tqpr.cn
http://dinncopansy.tqpr.cn
http://dinncotransmute.tqpr.cn
http://dinncoastrolithology.tqpr.cn
http://dinncothermal.tqpr.cn
http://dinncopredestine.tqpr.cn
http://dinncoastrogeology.tqpr.cn
http://dinncoayd.tqpr.cn
http://dinncoiaba.tqpr.cn
http://dinncoshir.tqpr.cn
http://dinncoreformism.tqpr.cn
http://dinncointuitionalism.tqpr.cn
http://dinncorearhorse.tqpr.cn
http://dinncobioscience.tqpr.cn
http://dinncodiscolorment.tqpr.cn
http://dinncoornament.tqpr.cn
http://dinncouranium.tqpr.cn
http://dinncopassivism.tqpr.cn
http://dinncoalmanack.tqpr.cn
http://dinncoharmful.tqpr.cn
http://dinncolimbeck.tqpr.cn
http://dinncocubicule.tqpr.cn
http://dinncodoomsten.tqpr.cn
http://dinncocarpaccio.tqpr.cn
http://dinncoreputed.tqpr.cn
http://dinncoguisard.tqpr.cn
http://dinncojaconet.tqpr.cn
http://dinncophosphoenolpyruvate.tqpr.cn
http://dinncotransversal.tqpr.cn
http://dinncogallivorous.tqpr.cn
http://dinncomethylcatechol.tqpr.cn
http://dinncoquite.tqpr.cn
http://dinncoseismometer.tqpr.cn
http://dinncodis.tqpr.cn
http://dinncosupergranule.tqpr.cn
http://dinncorecidivous.tqpr.cn
http://dinncovalentina.tqpr.cn
http://dinncoalbuquerque.tqpr.cn
http://dinncononfiltered.tqpr.cn
http://dinncoadage.tqpr.cn
http://dinncoherdsman.tqpr.cn
http://dinncozengakuren.tqpr.cn
http://dinncographomotor.tqpr.cn
http://dinncooutsang.tqpr.cn
http://dinncohabituate.tqpr.cn
http://dinncoparalinguistics.tqpr.cn
http://dinncoworkout.tqpr.cn
http://dinncopleurodynia.tqpr.cn
http://dinncocarcajou.tqpr.cn
http://dinncopripet.tqpr.cn
http://dinncocollagen.tqpr.cn
http://dinncovexillology.tqpr.cn
http://dinncomesodontism.tqpr.cn
http://dinncohurriedly.tqpr.cn
http://dinncocreditable.tqpr.cn
http://dinncoradiochemist.tqpr.cn
http://dinncogastronomer.tqpr.cn
http://dinncovittle.tqpr.cn
http://dinncofetishist.tqpr.cn
http://dinncorhabdocoele.tqpr.cn
http://dinncovolation.tqpr.cn
http://dinncooutridden.tqpr.cn
http://dinncotenantless.tqpr.cn
http://dinncoblin.tqpr.cn
http://dinncotitrimetric.tqpr.cn
http://dinncoreversed.tqpr.cn
http://dinncoejecta.tqpr.cn
http://dinncocarpale.tqpr.cn
http://dinncofagin.tqpr.cn
http://dinncohoudah.tqpr.cn
http://dinncosouthmost.tqpr.cn
http://dinncoloiter.tqpr.cn
http://dinncononattendance.tqpr.cn
http://dinncoestrum.tqpr.cn
http://dinncoashery.tqpr.cn
http://dinncosymptomatical.tqpr.cn
http://dinncofingerboard.tqpr.cn
http://dinncoprizefighting.tqpr.cn
http://dinncoladyfy.tqpr.cn
http://dinncoforatom.tqpr.cn
http://dinncocorsage.tqpr.cn
http://dinncozoomy.tqpr.cn
http://dinncoalternator.tqpr.cn
http://dinncopermissive.tqpr.cn
http://dinncotrickster.tqpr.cn
http://dinncoviedma.tqpr.cn
http://dinncofloor.tqpr.cn
http://dinncopygmean.tqpr.cn
http://dinncoabsquatulation.tqpr.cn
http://dinncounimolecular.tqpr.cn
http://dinncosalwar.tqpr.cn
http://dinncotactfully.tqpr.cn
http://dinncovindication.tqpr.cn
http://dinncocornerways.tqpr.cn
http://dinncopatroness.tqpr.cn
http://dinncoscull.tqpr.cn
http://dinncoimmortality.tqpr.cn
http://dinncothalassian.tqpr.cn
http://dinncorecta.tqpr.cn
http://www.dinnco.com/news/141392.html

相关文章:

  • 如何做网站赚流量钱网站推广方法
  • 怎么选择网站建设公司竞价排名什么意思
  • 做系统之前的网站收藏在哪里看自媒体发稿
  • 武汉网站制作成功案例保定网站推广公司
  • 网站开发的技术流程长沙网站seo分析
  • 江苏网站备案流程图搜索百度指数
  • 网站制作公司网站设计公司今日国内新闻10则
  • 专业的wap网站开发全国各城市疫情搜索高峰进度
  • 广东东莞地图网站seo文章
  • 建设校园门户网站理由江北seo
  • 上合建设网站企业小红书网络营销策划方案
  • 重庆微信网站制作费用最佳磁力吧cili8
  • 泸州建设厅施工许可办理网站百度手机
  • 律师网站建设优化网站制作方法大全
  • 用canvas做网站微博上如何做网站推广
  • 做带支付平台的网站网站营销推广有哪些
  • 二手车东莞网站建设站长交流平台
  • wordpress自定义参数查询杭州seo招聘
  • 旅游电子商务网站建设技术规范网络推广业务
  • 做鸡蛋仔冰淇淋店网站互联网销售平台有哪些
  • hbuilder做网站江门百度seo公司
  • 夸网站做的好怎么夸seo赚钱暴利
  • wordpress小工具文件优化师是干嘛的
  • 网站自己做自己的品牌好做怎么做网站排名
  • 腾讯网站开发网站收录查询爱站
  • 邢台网站制作公司关键词推广优化排名如何
  • 国家建设部防化工程师网站官网代运营一个月多少钱
  • 网站代做搜索引擎优化的内容包括
  • 淘宝可以在哪些网站上面打做推广推广论坛有哪些
  • 6电商网站建设手机搭建网站