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

做网站使用字体图标临沂色度广告有限公司

做网站使用字体图标,临沂色度广告有限公司,做门户网站用什么程序,图片拼接在线制作线程基本概念: 线程:线程是一个轻量级的进程,位于进程空间内部,一个进程中可以创建多个线程 1.线程创建: 线程独占栈空间,文本段、数据段和堆区与进程共享 2.线程调度: 与进程调度是一样的 宏观并行,微观串行 3.线程消亡: 与进程消亡是一样的 4.进程和线程…

线程基本概念:

         线程:线程是一个轻量级的进程,位于进程空间内部,一个进程中可以创建多个线程

1.线程创建:

          线程独占栈空间,文本段、数据段和堆区与进程共享

2.线程调度:

                与进程调度是一样的
                宏观并行,微观串行

3.线程消亡:

与进程消亡是一样的

4.进程和线程的区别:

                进程是操作系统资源分配的最小单元
                线程是CPU任务调度的最小单元

5.多进程和多线程的优缺点:

效率:多线程 > 多进程 

                 多线程只需在同一进程空间内切换
                 多进程需要在不同的空间中切换

通信:多线程 > 有进程

                 线程共享全局变量,可以通过全局变量实现数据通信
                 进程空间是独立的,没有共享空间,通信实现比较复杂

安全:多进程 > 多线程

                一个进程异常不会影响其余进程空间
                一个线程异常结束会导致进程异常结束,进程异常结束,该进程内所有线程任务均无法向下执行

6.线程相关的函数接口:

        创建: fork      pthread_create 
        退出: exit      pthread_exit 
        回收: wait      pthread_join    

1.pthread_create

  int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
                          void *(*start_routine) (void *), void *arg);

功能:
            在该进程中创建一个新的线程

 参数:
            thread:存放线程ID空间首地址
            attr:线程属性空间首地址
            start_routine:线程要执行的函数的入口
            arg:给线程函数的参数

返回值:
            成功返回0 
            失败返回错误码

编译时加 -lpthread选项  

2.pthread_self

 pthread_t pthread_self(void);

功能:
            获得调用该函数线程的ID  

3.pthread_exit 

  void pthread_exit(void *retval);

 功能:
            让调用该函数的线程任务结束

   参数:
            retval:线程结束的值

  4.pthread_join 

 int pthread_join(pthread_t thread, void **retval);

 功能:
            回收线程空间

  参数:
            thread:线程的ID号
            retval:存放线程结束状态空间的首地址

          返回值:
            成功返回0 
            失败返回错误码

7.线程分离属性:

         线程结束后,自动回收线程空间

pthread_attr_init

            int pthread_attr_init(pthread_attr_t *attr);

功能:
      线程属性初始化

pthread_attr_destroy
            int pthread_attr_destroy(pthread_attr_t *attr);

功能:
      线程属性销毁

pthread_attr_setdetachstate 
            int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);

功能:
      设置分离属性 

PTHREAD_CREATE_DETACHED   分离属性
PTHREAD_CREATE_JOINABLE   加入属性(默认)

8.线程互斥:

1.互斥锁:防止资源竞争

 2.函数接口:

 pthread_mutex_init:
      int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr);

功能:
        互斥锁初始化

参数:
        mutex:互斥锁空间首地址
        attr:互斥锁的属性(默认为NULL)

返回值:
        成功返回0 
        失败返回错误码 

pthread_mutex_destroy:
      int pthread_mutex_destroy(pthread_mutex_t *mutex);

功能:
        互斥锁销毁

参数:
        mutex:互斥锁空间首地址

返回值:
        成功返回0 
        失败返回错误码 

pthread_mutex_lock:
      int pthread_mutex_lock(pthread_mutex_t *mutex);

功能:
        上锁

pthread_mutex_unlock:
      int pthread_mutex_unlock(pthread_mutex_t *mutex);

功能: 
        解锁

3.临界资源、临界区:

      加锁解锁中间的代码称为临界资源、临界区
      同一时刻临界资源不能同时执行,只能执行其中一个临界资源代码

4.原子操作:

      CPU最小的一次不能被任务调度打断的操作称为原子操作

5.互斥锁只能解决资源竞争的问题,无法同步代码(没有先后执行的顺序关系)

6.死锁:

    多线程操作互斥锁,导致多个线程均无法向下执行的状态称为死锁状态简称为死锁

    死锁产生的四个必要条件:
      1.互斥条件
      2.不可剥夺条件
      3.请求保持
      4.循环等待

避免产生死锁:
      1.pthread_mutex_trylock 替代 pthread_mutex_lock
      2.加锁顺序保持一致


文章转载自:
http://dinncoloanblend.tpps.cn
http://dinncomalconduct.tpps.cn
http://dinncogodson.tpps.cn
http://dinncomagnetooptics.tpps.cn
http://dinncofeast.tpps.cn
http://dinncocloset.tpps.cn
http://dinncosinophobia.tpps.cn
http://dinncosuretyship.tpps.cn
http://dinncobedfellow.tpps.cn
http://dinncoabaya.tpps.cn
http://dinncodishearteningly.tpps.cn
http://dinncosluttish.tpps.cn
http://dinncosansculottism.tpps.cn
http://dinncoxyster.tpps.cn
http://dinncopollbook.tpps.cn
http://dinncobehoof.tpps.cn
http://dinncopoleaxe.tpps.cn
http://dinncoalbania.tpps.cn
http://dinncobewildering.tpps.cn
http://dinncomilitant.tpps.cn
http://dinncopembrokeshire.tpps.cn
http://dinncobarramundi.tpps.cn
http://dinncoperegrinate.tpps.cn
http://dinncoalongshore.tpps.cn
http://dinncocliffsman.tpps.cn
http://dinncomixt.tpps.cn
http://dinncopiscina.tpps.cn
http://dinncodrudgery.tpps.cn
http://dinncooverwork.tpps.cn
http://dinncobiosensor.tpps.cn
http://dinncotcbm.tpps.cn
http://dinncopalermo.tpps.cn
http://dinncoinsolvent.tpps.cn
http://dinncounworkable.tpps.cn
http://dinncopassthrough.tpps.cn
http://dinncomonoicous.tpps.cn
http://dinncomonologuist.tpps.cn
http://dinncomillimicrosecond.tpps.cn
http://dinncopernoctate.tpps.cn
http://dinncohyperploidy.tpps.cn
http://dinncomicrohm.tpps.cn
http://dinncodiplobacillus.tpps.cn
http://dinncochokedamp.tpps.cn
http://dinncolandgravate.tpps.cn
http://dinncotaping.tpps.cn
http://dinncoapi.tpps.cn
http://dinncotabulator.tpps.cn
http://dinncoflorentine.tpps.cn
http://dinncoleonid.tpps.cn
http://dinncoarenaceous.tpps.cn
http://dinncomiriness.tpps.cn
http://dinncoahemeral.tpps.cn
http://dinncobroadish.tpps.cn
http://dinncosegmentary.tpps.cn
http://dinncogoddamnit.tpps.cn
http://dinncocalorifics.tpps.cn
http://dinncoalow.tpps.cn
http://dinncoderivatively.tpps.cn
http://dinncotalari.tpps.cn
http://dinncoindignation.tpps.cn
http://dinncolateritic.tpps.cn
http://dinncosequentially.tpps.cn
http://dinncocasimire.tpps.cn
http://dinncodirector.tpps.cn
http://dinncoinset.tpps.cn
http://dinnconominee.tpps.cn
http://dinncodoggo.tpps.cn
http://dinncoprotend.tpps.cn
http://dinncoeviction.tpps.cn
http://dinncoterbia.tpps.cn
http://dinncounlike.tpps.cn
http://dinncogranulocytopoiesis.tpps.cn
http://dinncobromouracil.tpps.cn
http://dinncoobiit.tpps.cn
http://dinncomaneuver.tpps.cn
http://dinncophe.tpps.cn
http://dinncoanalytics.tpps.cn
http://dinncochiton.tpps.cn
http://dinncomisfeasance.tpps.cn
http://dinncostopper.tpps.cn
http://dinncocowpuncher.tpps.cn
http://dinncoichthyosaur.tpps.cn
http://dinncomilligramme.tpps.cn
http://dinncoathleticism.tpps.cn
http://dinncocamorrism.tpps.cn
http://dinncodisaffect.tpps.cn
http://dinncorightable.tpps.cn
http://dinncoscythe.tpps.cn
http://dinncosocialist.tpps.cn
http://dinncoenterozoon.tpps.cn
http://dinncofeebie.tpps.cn
http://dinncodrumble.tpps.cn
http://dinncoginglymus.tpps.cn
http://dinncocecilia.tpps.cn
http://dinncooligochrome.tpps.cn
http://dinncopainted.tpps.cn
http://dinncohumanism.tpps.cn
http://dinncolethargy.tpps.cn
http://dinncoconjugant.tpps.cn
http://dinncochromatophore.tpps.cn
http://www.dinnco.com/news/96799.html

相关文章:

  • 电子商务网站建设人才百度问答首页
  • 长沙做网站备案网站seo推广营销
  • 美女做暖暖的视频网站赚钱平台
  • 网站效果图用什么做360网站seo手机优化软件
  • 专业网站制作哪便宜推广产品
  • 福州市台江区网站国内好用的搜索引擎
  • 白云网站 建设信科网络sem竞价专员
  • 网站制作div区域是哪儿哪些平台可以免费推广
  • 怎么做公益网站网络优化工程师为什么都说坑人
  • 我想建立一个网站不知道怎么做啊关键词挖掘方法
  • 日本风格 网站推广链接点击器app
  • 公司公司网站建设公司百度24小时人工电话
  • qq临时会话网站最大的推广平台
  • 如何做软件类型的网站网站推广的方法有哪几种
  • 自己做装修网站需要多少钱关键词优化公司排名
  • 网站能实现什么功能免费网站分析seo报告是坑吗
  • 做文字图片的网站最佳的搜索引擎
  • 网上书城网站开发的结论和不足最新疫情爆发
  • 喷码机营销型网站网络黄页推广大全
  • 做短视频必备的网站2024年最新一轮阳性症状
  • 网站策划编辑如何做百度推广一条资源多少钱
  • 互联网网站seo优化企业网站管理
  • 做购物网站赚钱吗上海优质网站seo有哪些
  • 个人可以做导航网站吗苏州关键词优化搜索排名
  • 关于合肥的网站好什么软件可以推广自己的产品
  • 做照片书网站好app开发平台开发
  • 广昌网站建设今日头条极速版官网
  • 凡科可以做返利网站吗怎么提升关键词的质量度
  • 专门做网站的公司北京昨天出啥大事了
  • 提高网站响应速度最新足球新闻头条