struct binder_ Node description

King of heaven and earth tiger 626 2021-04-01 12:25:17 阅读数:924

本文一共[544]字,预计阅读时长:1分钟~
struct binder_ binder node description

struct binder_node {            
    int debug_id;               // Help debug with

    // When Binder The reference count of entity objects is determined by 0 Turn into 1 Or by the 1 Turn into 0 when ,Binder The driver will request the corresponding
    // Service Component increases or decreases its reference count .Binder The driver will “ The reference count is modified ” Encapsulate into a class
    // Type is a type of binder_node Work items of , Soon to be members of work The value of is set to BINDER_WORK_NODE, And will
    // It is added to the todo Waiting in the queue for processing
    struct binder_work work;

    union {
        struct rb_node rb_node;
        struct hlist_node dead_node;
    };

    // Point to the host process , The host process uses a red black tree to maintain all of its internal Binder Entity object , And every one
    // Binder Member variables of entity objects rb_node It's just a node of the red black tree . If Binder Entity object
    // The host process of is dead , Then the Binder The entity object passes through its member variables dead_node Keep it in a full
    // Bureau's hash In the list .
    struct binder_proc *proc;

    // One Binder Entity objects can be used by multiple objects at the same time Client Component references , therefore Binder Drive uses structure
    // binder_ref To describe these references , And it's going to refer to the same Binder All references to entity objects are saved in
    // One hash In the list . This hash The list goes through Binder Of a physical object refs Members to describe , and Binder Drive through
    // too refs You'll know what Client Component references the same Binder Entity object
    struct hlist_head refs;

    int internal_strong_refs;       // describe Bidner Strong reference count of entity objects
    int local_weak_refs;            // describe Binder Weak reference count of entity objects
    int local_strong_refs;          // describe Bidner Strong reference count of entity objects

    void __user *ptr;       // Describe... In user space Service Components , Point to Service The shadow object of
    void __user *cookie;    // Describe... In user space Service Address of component , Point to Service The address of

     // When Binder Entity object request Service When performing an operation , Will increase the Service Strong / Weak reference count ,
     // has_strong_ref and has_weak_ref Be placed 1;
     // When Service complete Binder After the requested operation , It's going to be Service Strong / Weak reference count ,has_strong_ref and has_weak_ref Be placed 0;
     // Binder The entity is requesting Service increase / Strength reduction / In the process of weak reference counting , Will
     // pending_strong_ref or pending_weak_ref Set up 1;
     // When Service Complete the addition / Strength reduction / After the weak reference count , Will set these two member variables to 0.
    unsigned has_strong_ref:1;     
    unsigned pending_strong_ref:1;
    unsigned has_weak_ref:1;
    unsigned pending_weak_ref:1;

    // describe Binder Object is processing an asynchronous transaction .Binder The driver saves a transaction in todo In line
    // Indicates that the transaction will be processed by the thread . Each transaction is associated with a Binder Entity object , Demand and the Binder real
    // Body objects correspond to Service Component processes the transaction in the specified thread . However , When Binder The driver finds that a transaction is different
    // When you step into a transaction , It will be saved in the target Binder In an asynchronous transaction queue for an entity object , This asynchronous transaction queue is
    // It's a member variable async_todo To describe the . Asynchronous transactions are defined as one-way interprocess communication requests , That is, there is no need to
    // Interprocess communication request to wait for response , The opposite is synchronous transactions . Because you don't have to wait for an answer ,Binder Drive on
    // Asynchronous transactions are considered to have lower priority than synchronous transactions , Specifically, at the same time , One Binder All asynchronies of entity objects
    // At most one transaction will be processed , The rest is waiting in the asynchronous transaction queue , There is no limit to synchronous transactions .
    unsigned has_async_transaction:1;

    // describe Binder Whether entity objects can receive interprocess communication data containing file descriptors .1 Indicates that it can be received ,0 surface
    // It is forbidden to receive . When data sent by one process to another contains a file descriptor ,Binder The driver just
    // Will automatically open the same file in the target process . Based on security considerations ,Binder The program will use this variable to prevent
    // The source process opens the file in the target process .
    unsigned accept_fds:1;

    // Express Binder The entity object in the Client Process request , The processing thread he asked for ( namely Server process
    // One thread in ) Minimum thread priority .
    unsigned min_priority:8;       
    struct list_head async_todo;
};
 

版权声明:本文为[King of heaven and earth tiger 626]所创,转载请带上原文链接,感谢。 https://netfreeman.com/2021/03/20210330012652580B.html