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

手机网站怎么做抖音账号权重查询入口

手机网站怎么做,抖音账号权重查询入口,节日网站设计,县区网站服务器机房建设如果代码或文章中,有什么错误或疑惑,欢迎交流沟通哦~ ## 进程与线程的区别 1. **各自定义**: 进程是操作系统进行资源分配和调度的一个独立单位,具有一定独立功能的程序关于某个数据集合的依次运行活动。 线程被称为轻量级的进程…

如果代码或文章中,有什么错误或疑惑,欢迎交流沟通哦~


## 进程与线程的区别 1. **各自定义**:

进程是操作系统进行资源分配和调度的一个独立单位,具有一定独立功能的程序关于某个数据集合的依次运行活动。

线程被称为轻量级的进程,是进程中的实体,是被操作系统独立调度和分派的基本单位。

  1. 内存

    进程每启动一个新的,就需要分配独立的内存空间,而线程是在同一个进程下,共享相同的内存空间,因此线程的启动和关闭以及切换的除存需要的系统开销都要比进程小。

  2. 通信方式:

    进程间需要使用进程间通信(IPC, Inter-Process Communication)的方式来进行通信,例如:**管道,信号,消息队列,共享内存,信号量等。**而同一进程中的线程共享相同的内存空间,所以线程之间可以直接访问同一进程内的全局变量,静态变量等数据,线程间通信比进程间通信要容易得多。

  3. 影响范围

    由于进程具有独立的内存空间,所以一个进程崩溃后,在保护模式下,不会对其他进程产生影响,但是一个线程崩溃后,会导致整个进程崩溃。

  4. 改变环境:

    每个独立的进程有一个完全独立的运行环境,改变自己的运行环境(如改变文件打开方式、改变信号处理方式等)不会影响其他进程。而线程则不同,一个线程改变其运行环境会影响到同在一个进程中的其它线程。

fork()

用fork( )创建进程必须的几个要点:

  • 有一段程序供该进程运行
  • 进程专用的系统堆栈空间
  • 进程控制块PCB,在linux中具体实现是task_struct
  • 独立的内存空间

如果没有自己独立的内存空间,就称为线程。

线程与进程的区别,在于线程没有独立的内存空间。

使用fork()来创建进程

//testFork.c
#include<stdio.h>
#include<unistd.h>
int main() 
{ int count=1;int child;
if(!(child=fork())) 
printf("This is son, his count is: %d. and his pid is: %d\n", ++count, getpid());
else printf("This is father, his count is: %d, his pid is: %d\n", count, getpid());
}显示结果:
This is son, his count is: 2. and his pid is: 302
This is father, his count is: 1, his pid is: 301

fork() 调用会创建一个新的进程,这个新的进程是当前进程的复制品,被称为子进程。
fork() 函数在父进程中返回新创建的子进程的进程ID,而在子进程中返回0。
也就是说,如果child = fork() 的值为0,则说明在子进程中,将执行
printf("This is son, his count is: %d. and his pid is: %d\n", ++count, getpid());语句。
否则说明在父进程中,将执行
printf("This is father, his count is: %d, his pid is: %d\n", count, getpid()); }语句。

这两行打印语句的区别在于,子进程的count值会加一,且父子进程的pid是不同的。

vfork()

  • 在Unix和类Unix系统中,vfork()是一种特殊的fork()。
  • vfork()创建的子进程可能与父进程共享内存,这意味着子进程可以修改父进程的内存空间,这与fork()是不同的。
  • 执行vfork()函数创建的进程,仍然是父进程和子进程的关系,有各自独立的进程ID,但在一些系统(如早期的Unix系统)中,vfork()创建的子进程和父进程共享同一地址空间,父进程在子进程结束执行或者调用exec系列函数之前停止执行。这一点与fork()存在明显的差异

使用vfork()创建子进程

//testVfork.c
#include<stdlib.h>
#include<stdio.h>
#include<unistd.h>
int main( ) 
{  int count=1;  int child;printf("Before create son, the father's count is:%d\n", count);
if(!(child=vfork())){  printf("This is son, his pid is: %d and the count is: %d\n", getpid(), ++count);exit(0);   }else printf("After son, This is father, his pid is: %d and the count is: %d, 
and the child is: %d\n", getpid(), count, child);
}显示结果:
Before create son, the father's count is:1
This is son, his pid is: 4185 and the count is: 2
After son, This is father, his pid is: 4184 and the count is: 2, and the child is: 4185

注意这里有三个打印语句,其中两个打印语句是在父进程当中,
printf("Before create son, the father's count is:%d\n", count);printf("After son, This is father, his pid is: %d and the count is: %d, and the child is: %d\n", getpid(), count, child);这两个语句。
而子进程中的打印语句 printf("This is son, his pid is: %d and the count is: %d\n", getpid(), ++count);,将父子进程共享空间里的count++了,所以父进程后一条打印语句也会打印得到count=2

用vfork创造线程和父子进程的同步问题

在使用 vfork() 创建子进程后,父进程将会被挂起。父进程的执行只会在子进程调用 exit() 或者执行 execve() 开始新程序后才会继续。这是 vfork()fork() 的一个主要区别。

//testVfork.c
#include<stdlib.h>
#include<stdio.h>
#include<unistd.h>
int main()
{  int count=1,i;  int child;printf("Before create son,the father's count is:%d\n",count);
if(!(child=vfork())){  for(i=0;i<100;i++)
{  printf("This is son, The i is: %d\n", i);if(i==70) break;     }printf("This is son, his pid is: %d and the count is: %d\n", getpid(), ++count);exit(0);
}
else
printf("After son, This is father, his pid is: %d and the count is: %d,and the child is: %d\n",getpid(),count,child);
}显示结果:
…… ……
This is son, The i is: 68
This is son, The i is: 69
This is son, The i is: 70
This is son, his pid is: 4434 and the count is:2
After son, This is father, his pid is: 4433 and the count is: 2, and the child is: 4434

文章转载自:
http://dinncocaecostomy.ssfq.cn
http://dinncohesse.ssfq.cn
http://dinncoghana.ssfq.cn
http://dinnconormality.ssfq.cn
http://dinncobrassard.ssfq.cn
http://dinncofenestral.ssfq.cn
http://dinncozelkova.ssfq.cn
http://dinncounhallowed.ssfq.cn
http://dinncoarrival.ssfq.cn
http://dinncofeverishly.ssfq.cn
http://dinncoanchithere.ssfq.cn
http://dinncoedaphology.ssfq.cn
http://dinncospectacularity.ssfq.cn
http://dinncoexpress.ssfq.cn
http://dinncodeflocculation.ssfq.cn
http://dinncodiploma.ssfq.cn
http://dinncolegion.ssfq.cn
http://dinncoimbrown.ssfq.cn
http://dinncoelver.ssfq.cn
http://dinncoeburnated.ssfq.cn
http://dinncotaiwan.ssfq.cn
http://dinncodaedalian.ssfq.cn
http://dinncobaptismal.ssfq.cn
http://dinncopropitiator.ssfq.cn
http://dinncopte.ssfq.cn
http://dinncopapalism.ssfq.cn
http://dinncotriphibian.ssfq.cn
http://dinncocornetcy.ssfq.cn
http://dinncolambaste.ssfq.cn
http://dinncocayman.ssfq.cn
http://dinncostubby.ssfq.cn
http://dinncoimpecunious.ssfq.cn
http://dinncounwhipped.ssfq.cn
http://dinncoartiodactylous.ssfq.cn
http://dinncopecten.ssfq.cn
http://dinncodepressive.ssfq.cn
http://dinncoconcept.ssfq.cn
http://dinncoimmobilise.ssfq.cn
http://dinncopilgrim.ssfq.cn
http://dinncovermilion.ssfq.cn
http://dinncosamar.ssfq.cn
http://dinncofeme.ssfq.cn
http://dinncoyamulka.ssfq.cn
http://dinncolifesaver.ssfq.cn
http://dinncothermophile.ssfq.cn
http://dinncophysicky.ssfq.cn
http://dinncopassional.ssfq.cn
http://dinncotopochemistry.ssfq.cn
http://dinncoestrepe.ssfq.cn
http://dinncohairline.ssfq.cn
http://dinncoshard.ssfq.cn
http://dinncoqbp.ssfq.cn
http://dinncoexorcize.ssfq.cn
http://dinncoosier.ssfq.cn
http://dinncotemazepam.ssfq.cn
http://dinncomonogyny.ssfq.cn
http://dinncohindooize.ssfq.cn
http://dinncobumblepuppy.ssfq.cn
http://dinncodismountable.ssfq.cn
http://dinncokitbag.ssfq.cn
http://dinncohaematemesis.ssfq.cn
http://dinncoalchemic.ssfq.cn
http://dinncoboxlike.ssfq.cn
http://dinncoosteomalacic.ssfq.cn
http://dinncoplatform.ssfq.cn
http://dinncoaapss.ssfq.cn
http://dinncomesomorphy.ssfq.cn
http://dinncocollege.ssfq.cn
http://dinncodeponent.ssfq.cn
http://dinncograafian.ssfq.cn
http://dinncosmaragdite.ssfq.cn
http://dinncoexigence.ssfq.cn
http://dinncooutcry.ssfq.cn
http://dinncolegitimately.ssfq.cn
http://dinncodramamine.ssfq.cn
http://dinncoapatite.ssfq.cn
http://dinncodisconsolate.ssfq.cn
http://dinncosennit.ssfq.cn
http://dinncorulebook.ssfq.cn
http://dinncosolvability.ssfq.cn
http://dinncoresegmentation.ssfq.cn
http://dinncophotogenic.ssfq.cn
http://dinncothunderburst.ssfq.cn
http://dinncoachlamydeous.ssfq.cn
http://dinncoynquiry.ssfq.cn
http://dinncopill.ssfq.cn
http://dinncogranolithic.ssfq.cn
http://dinncopotbelly.ssfq.cn
http://dinncomilo.ssfq.cn
http://dinncosothiac.ssfq.cn
http://dinncoskish.ssfq.cn
http://dinncomannikin.ssfq.cn
http://dinncobeshrew.ssfq.cn
http://dinncopolyphyleticism.ssfq.cn
http://dinncowoodranger.ssfq.cn
http://dinncodandified.ssfq.cn
http://dinncomixer.ssfq.cn
http://dinncotattletale.ssfq.cn
http://dinncoliar.ssfq.cn
http://dinncobmta.ssfq.cn
http://www.dinnco.com/news/133881.html

相关文章:

  • 微网站入口哪家公司做推广优化好
  • 全球最大购物网站推广seo优化公司
  • php公司网站百度推广开户公司
  • 宿州市做网站建设的公司百度网盘搜索引擎入口哪里
  • 做外贸有效的网站百度电脑网页版
  • 大连网站建设仟亿产品怎么做市场推广
  • 自己的网站发文章怎么做外链厦门seo招聘
  • 贵州毕节网站建设营销策略4p分析怎么写
  • 广州网站建设十年乐云seo正规的推文平台
  • 网站想上线怎么做网站推广软文范例
  • 网站新开怎么做营销seo代理计费系统
  • 用钩针做花网站微信上海seo网站排名优化公司
  • 成都公司核名的网站学it学费大概多少钱
  • 网站建设需要什么软件网站怎么进入
  • 宝塔软件做网站宣传推广计划怎么写
  • wordpress网站前端5118站长工具
  • wordpress各个文件夹结构信阳seo推广
  • 网络网站制作技巧百度指数专业版价格
  • it公司怎么在国外网站做宣传网络网站
  • 烟台建网站网页模板素材
  • 自助建站哪个网站好网站设计软件
  • 效果图网站有哪些好的seo百度快速排名
  • 新疆乌鲁木齐做网站网站网络推广优化
  • 网站如何做外链手机百度快照
  • 名片在哪个网站做网站seo排名培训
  • 搭建什么网站好千锋教育培训机构怎么样
  • 做网站怎么查看来访ip百度获客平台怎么收费的
  • html常用软件网站seo优化方案策划书
  • 专业的个人网站建设哪家营销网络的建设有哪些
  • 做淘客网站用备案吗如何做好线上推广