Unix network programming 2 Reading Notes Chapter 2-Introduction

Source: Internet
Author: User

Unix network programming 2 Reading Notes Chapter 2-Introduction
1. Overview 2. process, thread, and information sharing

There are multiple ways to share information between Unix processes: Pay attention to the location of the kernel

  • The two processes on the left share some information stored on a file in the file system. To access this information, each process must traverse the kernel.
  • The two processes in the middle share some information in the kernel. Pipelines, System V message queues, and System V semaphores are all shared.
  • The two processes on the right have a shared memory zone that both parties can access. Once this shared memory area is configured for each process, the data in the shared memory area can be accessed without involving the kernel.
  • Note: The above IPC technology can act on any number of processes.
Thread
  • IPC between multiple processes, IPC of multiple threads in a single process
  • From the perspective of IPC, a global variable shared by all threads in a given process (that is, the concept of shared memory zone is built-in to this model ).
  • However, we must pay attention to the synchronous access to global data among various threads.
  • Although synchronization is not a clear IPC form, it does come along with many forms of IPC to control access to some shared data.
3. Continuity of IPC objects
  • Demonstrate three types of continuity: determine the duration of the IPC object
    1. the IPC object that persists with the process until the last process that opens the object closes the object. Such as pipelines and FIFO
  • 2. the IPC object that persists with the kernel until the kernel re-runs or explicitly deletes the object. For example, System V message queue, semaphore, and shared memory zone. Posix message queues, semaphores, and shared memory must at least be consistent with the kernel, but it can also be consistent with the file system, depending on the implementation.
  • 3. An IPC object that persists with the file system until it is explicitly deleted. The value of this object is retained even if the kernel is retained. If Posix message queues, semaphores, and shared memory areas are implemented using ing files, they continue with the file system.

    In most cases, IPC does not have the intention to continue to exist after the system reapplies, because it is impossible for a process to survive after reapplies. In addition, it is required that the persistence of the file system may reduce its performance, and a basic design goal of IPC is high performance.

4. namespace
  • When two or more unrelated processes exchange information with each other using some type of IPC object, the IPC object must have a certain form of name or identifier. In this way, a process (usually a server) can create this IPC object, while other processes can specify the same IPC object.
  • The pipeline has no name (so it cannot be used between unrelated processes ).
  • FIFO has a Unix path name in the file system as its identifier (so it can be used between unrelated processes ).
  • For a given IPC type, a set of possible names is called its namespace. Namespace is very important. For all forms of IPC except common pipelines, names are the means by which customers and servers connect to each other to exchange messages.

  • Summarizes the naming conventions used by different forms of IPC

    • 1. Considering unknown synchronization variables (mutex lock, condition variable, read/write lock, Posix memory-based semaphore), calling fork from a process with multiple threads will become messy.
    • 2. System v ipc is not enabled or disabled in three forms. To access these three forms of IPC objects, you only need to know their identifiers, so any process that knows the identifiers can access them.
    6. the IPC example index table in the book
    • File Server: Customer Service-server application. The customer sends a path name to the server, and the server returns the content of the file to the customer.

      Producer-consumer: one or more threads or processes (producers) place data in a shared buffer, and one or more threads or processes (consumers) operate the data in the shared buffer.

    • Serial number continues to increase by 1: one or more threads or processes continuously increase by 1 for a shared serial number. The serial number is sometimes in a shared file or in the shared memory.
    • Four main fields:

    1 ~ 2 famous books and notes

    Love Education

    I do not remember when I would like to read books from the preface, because in the preface, the painstaking efforts of the author or the translator are often collected. From the preface, often be able to understand important information related to works.
    When I put the recently purchased "Love Education" in my hand, I honestly started to look at the previous page. I was excited when I read "this translation is the first time I translated the entire book directly from Italian and followed the original contents and paragraphs", because the fate of famous books on the market is very miserable, the authenticity of different versions is hard to argue. The original flavor of "Love Education", translated by Liang Haitao and CAI Xueping from Yiwen, should be the strongest. I am glad that I got the best version I can read.
    This book is not suitable for educating my students. Although I already know that many teachers have listed this book as a necessary teaching material for students to educate themselves, even though the halo of world famous books has already been put on it, but I never go into the book.
    When I read the first few articles, I did not agree. I even felt a little annoyed to remember the name of the book, and the language seemed so plain that I didn't feel any touching or attractive.
    However, the title of "Famous Books" leads me to read all the way, and this reading is unmanageable. One day, I don't eat, my family doesn't clean up, and even my son pushed to his father, I am immersed in this world of love, how many times my tears burst!
    As he was busy carrying firewood and greeting the customer, he reviewed his homework, learned to cook coffee, and took care of his sick mother. He was so cheerful and optimistic when doing everything. My eyes were wet when he "prepared my mother's pillows and quilts for her. I was touched by a good, hardworking, optimistic, and considerate parent! What a rare quality is this? Which of the following children can do what corletty does? The same as the third-grade children, what is the difference between the "Qian" and "QIAN Jin" in my class!
    Tears wet my eyes again as Nari's mother glared in Carol's shoulder excitedly in the principal's office and "groomed" to find a gift for Carol. I understand the feelings of this mother. I can feel the worries of a mother about her hunched and thin son in school, and a heartfelt gratitude to Carol for protecting his son. I shed tears as a mother.
    Although I have read the Florence small document countless times (the subject in the Chinese textbook is the small copywriter), I have told the students this text many times, but when I read this article again in the book, I still can't control my tears, let it go. I believe that many fathers can do this with their children. Only this child has a deep affection for his father-he is willing to work hard for his father. He would rather not say anything when he is wronged for many times, how valuable is my love for my father! Which of our children can endure the grievance? Let alone grievance. Even if you do something wrong, you are often not allowed to criticize others!
    In six thousand, when the poor, strong, and brave little mark experienced the hardships and hardships, he came to the home of the engineers of maces; when the poor mother who misses her hometown, misses her relatives, and is waiting for her death to hear the "good news", she sits up and does not move her eyes ...... ", when Mark said," My shirt is worn out, and dust is standing at the door ...... ", my tears burst into my eyes, weeping with the mother and child! It is the love for the mother, supporting the 13-year-old little mark alone, traveling long distances, the ups and downs; it is the love for the mother, giving little mark a huge spiritual motivation, overcome the unimaginable difficulties of ordinary people (I think I can't do anything Mark does now), and finally saved my mother who is dying! Because of her son's love, the mother who has just rejected the Operation should undergo the operation immediately. To love and be loved, she should live!
    Even now, when I recall these stories, my eyes are wet when I write them! The power of love is so great!
    Of course, there are also laughter when reading.
    When encico and his mother appeared in kindergarten, when the little ones turned around their mothers and waited for their mothers to escape from kindergarten, "the whole body of breadcrumb and stains, messy hair ,...... "," From kindergarten, you can hear the children scream like birds: 'Goodbye! Goodbye! Come back! MRS !" Children's naive form, mother's tolerant and benevolent image,... the rest of the full text>

    Insects 1, 2 Reading Notes

    1. Everyone has their own talents and character. Sometimes this kind of character seems to have been inherited from our ancestors. However, it is very difficult to find out where these personalities come from. For example, one day when he saw a shepherd boy, he was counting a few small stones in a low voice, calculating the total number of these small stones, and taking this as a pastime, so he became a very famous professor when he grew up, finally, he may be a mathematician. In addition, there is another child who is much older than other children. Other children only pay attention to playing games, but he does not play with other children, instead, he fantasized about the sound of an instrument all day, so when he was alone, he heard a mysterious ensemble.
    2,
    Mysterious Pond

    When I stare at the pond, I never get bored. In this little green world
    I don't know how many busy little lives will be. A pile of Black is everywhere on the muddy pool edge.
    The little cockroaches play and chase in the warm pool water; the bulb with a red belly also put its wide tail like a rudder
    Swing and slowly move forward; in the reed grass, we can also find a group of silkworm larvae, it
    Each of them hides their bodies in a small sheath made of dead branches-this small sheath is used to defend against natural enemies and a variety of ideas
    Unexpected Disasters.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.