littlekernel / lk

LK embedded kernel
MIT License
3.14k stars 615 forks source link

What is the meaning of dpc system? #187

Open takboo opened 7 years ago

takboo commented 7 years ago

Recently i was study little kernel project, i'm curious the full name of dpc and where this system to use, thanks.

mu578 commented 7 years ago

@hello @takboo, it looks like you are using a translator tool or something ... likewise, may you refactor and please give us a bit of context ; if you are talking about kernel/dpc:

-> "deferred procedure call" if I am not mistaken
    -> you have a thread holding a queue of events
        -> then when thread runs
            -> for each events
                -> dispatch   event
                                -> invalidate  event
M1cha commented 7 years ago

Afaik @moe123 is right. dpc is used to make actions run later. In past it was used to free the current thread's stack when it exits but thread.c uses its own implementation now and dpc is unused.

takboo commented 7 years ago

@moe123 @M1cha thanks for your help. English is not my first language, if I use wrong words, please forgive me. kernel/dpc is the dpc i want to know. I found dpc_init in kmain(), i can understand the code, but i don't know the purpose for "dpc", so i ask this question. again, thanks for your help.

travisg commented 7 years ago

DPC stands for 'deferred procedure call'. It's currently unused in LK, but it basically is a simple little mechanism to force a function to be called on the context of a worker thread.

On Tue, May 16, 2017 at 7:02 PM, takboo notifications@github.com wrote:

@moe123 https://github.com/moe123 @M1cha https://github.com/m1cha thanks for your help. English is not my first language, if I use wrong words, please forgive me. kernel/dpc is the dpc i want to know. I found dpc_init in kmain(), i can understand the code, but i don't know the purpose for "dpc", so i ask this question. again, thanks for your help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/littlekernel/lk/issues/187#issuecomment-301964294, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF9rAzhoyvts7Ss8Wklbx-Er0WBLolJks5r6lUogaJpZM4NcD7f .

M1cha commented 7 years ago

@travisg is there unix-like terminology/alternative for this too? Googling dpc only gives you results for Microsofts DPC.

zeusk commented 7 years ago

@M1cha, tasklets and bottom half are used in linux in a pretty similar manner.

mu578 commented 7 years ago

@M1cha, @zeusk, @takboo, yes there are Tasklets which are close to in term of concept ; but this is more complex than simply delaying a bit some calls, indeed, Tasklets are interrupts aware, priorities, context... DPC ("Deferred Procedure Call" or job-queue/pool) is meant to add a bit of latency, crossing your fingers and letting it go, a really simple, lightweight and lock free mechanism, if always called from the same context, DPC ("Deferred Procedure Call" or job-queue/pool) handles the job well. You can find similar approaches in other kernels and kernel APIs such as network layers. That's indeed a really common "concept". You can name it whatever you want. Example:

-> procedure mount_hard_drive
    mount_hard_drive doesn't return (non-blocking) and won't notify you back

-> push_job_with_estimate_delay fs_hard_drive
        -> run
            sure if mount_hard_drive failed or took more time -> ka-boom