• advacing lnux program thread[copy]


    We’ve seen how a program can fork a child process.The child process is initially
    running its parent’s program, with its parent’s virtual memory, file descriptors, and so
    on copied.The child process can modify its memory, close file descriptors, and the like
    without affecting its parent, and vice versa.When a program creates another thread,
    though, nothing is copied.The creating and the created thread share the same memory
    space, file descriptors, and other system resources as the original. If one thread changes
    the value of a variable, for instance, the other thread subsequently will see the modi-fied

    value. Similarly, if one thread closes a file descriptor, other threads may not read

    from or write to that file descriptor. Because a process and all its threads can be exe-cuting only one program at a time, if any thread inside a process calls one of the exec
    functions, all the other threads are ended (the new program may, of course, create new
    threads).

  • 相关阅读:
    1026. 程序运行时间(15)
    C语言字符串/数组去重
    1025. 反转链表 (25)
    1024. 科学计数法 (20)
    1023. 组个最小数 (20)
    1022. D进制的A+B (20)
    1021. 个位数统计 (15)
    1020. 月饼 (25)
    前端001/正则表达式
    SSM001/构建maven多模块项目
  • 原文地址:https://www.cnblogs.com/michile/p/2890568.html
Copyright © 2020-2023  润新知