zoukankan      html  css  js  c++  java
  • clone() 操作系统实验

    吉大实验指导教材《操作系统习题与实验指导》,由左万历和焦素点老师主编的

    在做实验一的时候发现了两个问题:

    1. CLONE_SIGNAND。Linux Kernel 内根本没有这个常量,应该是 CLONE_SIGHAND

    2. 我们编写了一个程序,使用clone()创建四个轻进程。编译时出现如下错误:
    /tmp/ccYR00NJ.o(.text+0x48): In function `main':
    clone_call.c: undefined reference to `sem_init'
    /tmp/ccYR00NJ.o(.text+0x64):clone_call.c: undefined reference to `sem_init'
    /tmp/ccYR00NJ.o(.text+0x13f): In function `producer':
    clone_call.c: undefined reference to `sem_wait'
    /tmp/ccYR00NJ.o(.text+0x1d9):clone_call.c: undefined reference to `sem_post'
    /tmp/ccYR00NJ.o(.text+0x233): In function `consumer':
    clone_call.c: undefined reference to `sem_wait'
    /tmp/ccYR00NJ.o(.text+0x2a8):clone_call.c: undefined reference to `sem_post'
    collect2: ld returned 1 exit status

    原来我们编译的命令是
    gcc clone.c -o clone
    但是我们程序要使用多线程,所以要正确的编译参数是
    gcc -pthread clone.c -o clone

  • 相关阅读:
    range用法(倒序取值)
    set操作
    map集合 可变对象
    元组
    list操作
    列表推导式、字典推导式、集合推导式
    调用父类方法
    谷歌浏览器真机调试的方法
    css3 flex弹性盒自动铺满写法
    微信小程序保存海报的方法
  • 原文地址:https://www.cnblogs.com/wbb2109/p/clone.html
Copyright © 2011-2022 走看看