• Asynchronous Procedure Calls


    An asynchronous procedure call (APC) is a function that executes asynchronously in the context of a particular thread.

    QueueUserAPC

    A thread enters an alertable state when it calls the SleepEx, SignalObjectAndWait, MsgWaitForMultipleObjectsEx, WaitForMultipleObjectsEx, or WaitForSingleObjectEx function.

    The ReadFileEx, SetWaitableTimer, SetWaitableTimerEx, and WriteFileEx functions are implemented using an APC as the completion notification callback mechanism.

    If you are using a thread pool, note that APCs do not work as well as other signaling mechanisms because the system controls the lifetime of thread pool threads, so it is possible for a thread to be terminated before the notification is delivered. Instead of using an APC-based signaling mechanism such as the pfnCompletionRoutine parameter of SetWaitableTimer or SetWaitableTimerEx, use a waitable object such as a timer created with CreateThreadpoolTimer.

    1) With synchronous I/O, the thread builds the IRP, sends it to the device stack, and waits in the kernel for the IRP to complete.

    2) With asynchronous I/O, the thread builds the IRP and sends it to the device stack. The stack might complete the IRP immediately, or it might return a pending status indicating that the request is in progress.In the meantime, the thread can continue to perform other tasks while the device stack continues to process the IRP.

    Synchronization Objects

    Synchronization Objects
    Event Notifies one or more waiting threads that an event has occurred.
    Mutex Can be owned by only one thread at a time, enabling threads to coordinate mutually exclusive access to a shared resource.
    Semaphore Maintains a count between zero and some maximum value, limiting the number of threads that are simultaneously accessing a shared resource.
    Waitable timer Notifies one or more waiting threads that a specified time has arrived.
    Change notification Created by the FindFirstChangeNotification function, its state is set to signaled when a specified type of change occurs within a specified directory or directory tree.
    Console input Created when a console is create.The handle to console input is returned by the CreateFile function when CONIN$ is specified, or by the GetStdHandle function. Its state is set to signaled when there is unread input in the console's input buffer, and set to nonsignaled when the input buffer is empty.
    Job  
    Memory resource notification  
    Process  
    Thread  

    参考资料

    Asynchronous Procedure Calls

    Synchronization Objects

  • 相关阅读:
    Nhibernate对象转JSON
    C# Windows服务
    C# 接收http请求
    C# XML 基础解系
    C# XML 序列化与反序列化
    C# Newtonsoft.Json 应用
    C# 读取自定义XML
    对图片添加水印
    iText: 对pdf文件添加水印
    java对Office文件处理技术(介绍)
  • 原文地址:https://www.cnblogs.com/anyboo/p/13366423.html
Copyright © 2020-2023  润新知