#tyndur · 2009-11-23

303 Nachrichten · Seite 1 von 2 · Original-CSV herunterladen

  1. kwolfGood morning
  2. kwolfpcmattman: So you want to implement some generic IPC mechanism in CDI?
  3. pcmattmankwolf: I wouldn't label it "IPC", because it may not necessarily be inter-process, but yes, I do think there should be a method for device drivers to communicate with each other
  4. kwolfRight, not necessarily, but they need to be designed to allow implementing them by IPC
  5. pcmattmanAh, yes, I understand what you're saying
  6. kwolfI'm not sure what I should be thinking of it
  7. kwolfOn the one hand I have a feeling that it would be the clean solution for all future drivers
  8. kwolfOn the other hand, I'm scared ;-)
  9. pcmattmanHeh :)
  10. pcmattmanIt's not an easy thing to design, really
  11. kwolfGetting the one IPC method right in your OS is difficult enough. I'm not sure what getting it right for all sorts of IPC is like...
  12. kwolfFor example, if shared memory is available, you surely want to use it. But should we make it a requirement for CDI?
  13. kwolfCreating an interface that looks the same for both variants seems hard to me
  14. pcmattmanI think ideally the IPC method would merely expose an interface to send "messages" to a "destination"
  15. pcmattmanFor example, cdi_ipc_send(void *msg, size_t length, const char *dest);
  16. pcmattmanThe method through which said message is routed is then totally up to the OS
  17. pcmattmanAnd then drivers might have something like cdi_ipc_register_dest(const char *dest, func_ptr callback) which links the "destination" to a callback
  18. kwolfI'd like to avoid copying msg, so I'd prefer implementing this as SHM. Which in turn means for tyndur that the page for msg needs to be allocated as SHM in the first place.
  19. pcmattmanPerhaps a method for obtaining IPC-specific memory then?
  20. pcmattmancdi_ipc_malloc(size_t) ?
  21. pcmattmanThat would solve that problem, as tyndur could implement that as allocating shared memory, and other OS's as some other mechanism
  22. kwolfCould work
  23. kwolfAre you sure that const char* dest is really helpful? I feel that an OS specific struct cdi_ipc_endpoint could be more appropriate
  24. pcmattmanHmm, good point
  25. pcmattmanThat'd probably make it easier to integrate into an existing IPC system
  26. kwolf_[11:04] <kwolf> But maybe I just don't see what you want the strings to look like
  27. pcmattman(8:05:21 PM) pcmattman: Hmm, good point
  28. pcmattman(8:06:00 PM) pcmattman: That'd probably make it easier to integrate into an existing IPC system
  29. kwolfNo need to repost your lines, #tyndur is logged ;-)
  30. pcmattmanAnd I was thinking driver defined strings, but that wouldn't solve the mixer communication problem at all in hindsight
  31. pcmattmanAh, good to know :)
  32. kwolfhttp://irc.tyndur.org/index.php
  33. kwolfJust in case you need it some time
  34. pcmattmanThanks
  35. kwolfThe problem with a string is that needs to be unique. Which would probably mean things like encoding driver PIDs in the string.
  36. pcmattmanYup, and to be honest, I like the cdi_ipc_endpoint idea better
  37. pcmattmanIf it's OS-specific, you can store all kinds of useful information
  38. pcmattmanThere probably needs to be a way to enumerate all CDI IPC endpoints, and they probably need some form of well-defined control protocol
  39. kwolfI think (hope) there is no need for the drivers to look into the struct.
  40. pcmattmanThe control protocol would be something like "what type of device are you", if that makes sense
  41. pcmattmanWell, I imagine cdi_ipc_endpoint would be much like FILE in POSIX - don't depend on its layout
  42. kwolfRight. One of the existing constants?
  43. kwolfpcmattman: I agree
  44. pcmattmanYes, the control protocol can hook in to existing information
  45. pcmattmanThe control protocol might also add things such as "unload" in the future, but that's mere speculation
  46. kwolf"what type of device are you" would mean a cdi_device_type_t, right? CDI_NETWORK and so on.
  47. pcmattmanYup, that's what I was thinking
  48. kwolfOk. I think this mechanism is doable if someone volunteer to implement it. ;-) I guess it means no sound in 0.2.2, though...
  49. pcmattmanHmm, I'm going to be unable to code for most of December and part of January
  50. pcmattmanOtherwise I'd get in there and write it
  51. kwolfYeah, I read that in #pedigree. Lots of RL stuff to do?
  52. pcmattmanYup, and for part of that I won't even be internet connected
  53. kwolfEnjoy the time without internet. It's always amazing how much sleep one can get. ;-)
  54. pcmattmanHaha :)
  55. kwolfDo you think eddyb would be a help in this area, or would he rather be an impediment?
  56. pcmattmanI'm not sure
  57. pcmattmanIt would give him something to work on, while I'm away :)
  58. kwolfI wouldn't let him do the interface, but maybe porting the existing ac97 onto it or something like this
  59. pcmattmanRight, he'd probably be able to do that
  60. kwolfProbably he would also need to implement the IPC interface for Pedigree. But it will be mostly a nop, so he should manage to do it
  61. kwolfWe just need to agree on a concrete interface before, i.e. best a header file that contains all of the data structures and function prototypes
  62. pcmattmanRight, I can put together a proposal again in an email
  63. pcmattmanThe Pedigree CDI IPC interface will end up basically calling a callback function defined in cdi_ipc_endpoint, I imagine
  64. kwolfProbably with some pointer to a Device
  65. kwolfBut that should be really enough
  66. pcmattmanFor Pedigree, yes
  67. pcmattmanI don't know what tyndur would need
  68. kwolfI think it's going to be minimally more sophisticated ;-)
  69. kwolfEspecially for the enumeration we need to introduce something new. But we'd need this anyway.
  70. pcmattmanI think it will be highly beneficial in the future with other drivers which need to communicate with each other
  71. kwolfDefinitely. We have the very same problem with USB, for example. Currently all of the USB related drivers are in one monolithic CDI driver.
  72. kwolfAt the same time I'm concerned about how difficult/time-consuming it might become to get CDI running. Maybe we need to define several "levels" of CDI implementations
  73. pcmattmanHmm, perhaps
  74. pcmattmanMaybe something like a "config.h" but for the OS to specify what it supports?
  75. kwolfYou mean like #define CDI_HAVE_IPC?
  76. pcmattmanYup
  77. pcmattmanA header like that, provided by the OS, which would switch on and off different features
  78. kwolfI suggested adding such defines myself earlier, so I think that makes a lot of sense.
  79. kwolfBy the way, have you read that thread in the osdev.org forum? I kind of hate it when people dream of UDI... ;-)
  80. kwolfWe should get CDI in a shape that we could advertise it more loudly in the community
  81. pcmattmanI agree
  82. pcmattmanAt the moment the problem is that nobody knows what CDI is, so they look at UDI and think it's the answer to life :)
  83. kwolfProbably it's me who needs to do the next step. Finally implementing the changes we discussed a month ago and adding English comments.
  84. pcmattmanI'd be happy to contribute, it's just difficult to start anything right now as I'm not going to be coding for a couple of months
  85. kwolfSo when does it start? (whatever "it" may be)
  86. pcmattmanSaturday 28 November
  87. kwolfOk, that's really soon
  88. pcmattmanYup
  89. kwolfAnd you'll be back end of January?
  90. pcmattmanProbably about halfway through
  91. pcmattmanI will still have access to email every now and then, and possibly IRC on my phone, but not coding
  92. kwolfSomehow we'll get by without you for some weeks ;-)
  93. kwolfafk
  94. pcmattmanI don't worry about you, I worry about my own project ;)
  95. kwolfBack
  96. pcmattmanWelcome back
  97. kwolfpcmattman: You mean eddyb will destroy it while you're away? ;-)
  98. pcmattmanPerhaps, I'm more concerned about the fact that it's a long time to be away; code that you haven't seen in a long time always looks worse ;)
  99. kwolfBut that's great. You can improve it then. ;-)
  100. pcmattmanYep, it's just always a lot of effort to improve :)
  101. kwolfWell, if you don't want to invest effort, you can stop developing an OS.
  102. pcmattmanWell, there's effort, of course
  103. pcmattmanBut effort to improve is usually also quite depressing ;)
  104. kwolfBut if you find a way how to let an OS create itself while you merely think about its design, let me know I could use that, too, at times ;-)
  105. pcmattmanHeh, we'd all be out of a job if such a thing existed
  106. FreakyPenguinGood Morning
  107. kwolfpcmattman: I'm curious what CDI redesign you'll bring up when you look at it again in January ;-)
  108. kwolfMoin FreakyPenguin
  109. FreakyPenguinpcmattman: Do you have some other possible applications (besides sound) in mind for such an "ipc" mechanism?
  110. pcmattmanGraphics, perhaps?
  111. FreakyPenguinIf I look at usb i think it would be a good idea to "hide" the communication between the different drivers in cdi, seems somhow cleaner to me...
  112. pcmattmanDo you mean via IPC, or remove communication at all?
  113. FreakyPenguinWell I think the drivers have to communicate somehow
  114. pcmattmanRight
  115. pcmattmanI also think a better term might be "IDC" - "Inter-driver communication", as it may not necessarily be between two processes
  116. kwolfBascially, the two options are a generic IPC mechanism or specific cdi_audio_mixer_* and cdi_usb_* functions
  117. pcmattmanBut that's purely aesthetic :)
  118. FreakyPenguinkwolf: That's what I had in mind, yes
  119. kwolfpcmattman: You're complety right, but everyone knows what IPC is and noone knows IDC ;-)
  120. FreakyPenguinThe second way looks somehow more structured and cleaner to me
  121. kwolfFreakyPenguin: The latter means that for each new device class we need to add more and more functions to the framework
  122. kwolfInstead of solving the problem just once
  123. kwolfObviously, solving the problem just once means that you need to get a complex thing right
  124. FreakyPenguinWell of course. But doesn't this mean that we take code out of the cdi implementation and duplicate it in each driver?
  125. kwolfFor example, we haven't even discussed what messages would look like
  126. kwolfDoes it?
  127. FreakyPenguinWell at least the code for handling the messages and splitting it up, into the different handlers, and somehow do synchronisation when sending some data back
  128. kwolfpcmattman: You don't feel like discussing this? I wanted to leave the answer to you. ;-)
  129. pcmattmanWell, I think communication between drivers is something CDI will need, and it'll help avoid clogging up the CDI interfac with lots of functions
  130. pcmattmanOn the other hand, implementing a new way of talking between drivers may be a lot of hard work and involve a lot of rewriting
  131. kwolfPossibly. But I think what FreakyPenguin is worried about is that your simple cdi_send_message isn't enough
  132. pcmattmanbbs
  133. pcmattmanBack
  134. pcmattmanAnd the cdi_send_message idea centers around each message being a part of a "protocol" between drivers
  135. pcmattmanThe control protocol defines the generics (type, etc...) while you have a more specific protocol for the device type (eg, for the mixer, it'd be centered around functionality to do with the mixer's relationship to devices)
  136. pcmattmanBut it's your driver interface, it's just an idea :)
  137. kwolfSo if you needed a response from the other driver, you would need to implement this logic for each driver, right?
  138. kwolfpcmattman: No, it's your driver interface as well
  139. pcmattmanWell, you'd need to reimplement the logic for the current drivers
  140. pcmattmanBut future drivers, it'd be just a part of writing that driver
  141. kwolfThe point is if this means a lot of code duplication
  142. kwolfCurrent drivers don't communicate with other drivers, so they won't need reimplementation
  143. pcmattmanPerhaps the common code, such as the control protocol, can be hidden away in a CDI function?
  144. pcmattmanThe only thing that's really going to be duplicated is the control protocol code, the other code is driver-specific (ie, mixer -> device interface will have one device handle messages differently from another device)
  145. kwolfWe have only one mixer, but n different sound drivers
  146. pcmattmanYup
  147. pcmattmanThe mixer has code to communicate with the sound drivers
  148. pcmattmanThe sound drivers take those messages (whatever they may be) and performs the action it needs to (which is device-specific)
  149. pcmattmanAn alternative that can get around the need for any communication is to allow drivers to access a list of other devices/drivers in the system
  150. kwolfFreakyPenguin: Do you have some specific example in mind where we would actually need a response or other more complicated communication patterns?
  151. kwolfpcmattman: How that? The mixer would still need to send to audio data, wouldn't it?
  152. pcmattmanWell, it can do that via the sound device interface
  153. pcmattman(cdi_audio_driver)
  154. pcmattmanI'm merely looking at another alternative here, in order to find where the IPC-style interface works better
  155. kwolfThis would lead to the solution with many cdi_usb_* and cdi_audio_* functions, I think
  156. pcmattmanPerhaps, but realistically the mixer (as an example) takes streams, mixes them into one output stream, and sends that to the sound device
  157. pcmattmanI don't know enough about USB in CDI to comment intelligently there, it's probably very different
  158. kwolfIt's basically nonexistent as of today ;-)
  159. pcmattmanThe way I see it, the mixer is going one way - Application -> Mixer -> Sound device - so two-way communication isn't necessary
  160. FreakyPenguin*g*
  161. pcmattmanHowever, USB is Application <-> Controller <-> Device (I *think* so anyway) - there's two-way communication everywhere
  162. FreakyPenguinkwolf: Well I don't know about usb either, but I had somthing in mind like reading some memory/storage/whatever, you have to send offset and size and get some data back.
  163. kwolfpcmattman: Hm... We can make audio two-way very easily. What about recording?
  164. pcmattmanI was really hoping someone wouldn't bring up recording ;)
  165. pcmattmanI think IPC may be a bit over-the-top for audio, but it may be just the right thing for USB
  166. kwolfYou're trying to talk us into a bad design, so you take over world domination alone? ;-)
  167. pcmattmanI also think IPC should be done on a per-device-class basis, not necessarily across the entire interface, to keep things simple
  168. kwolfI'm not sure what to think about IPC and "keep it simple" in one sentence.
  169. pcmattmanHaha
  170. FreakyPenguin*g*
  171. kwolfI mean we could easily expose the whole tyndur RPC functions to CDI, but I'm unsure if other OSes would like it
  172. pcmattmanI feel that IPC should be used as little as possible, where communication is required
  173. kwolfI'm not even sure if we would like it, to be honest ;-)
  174. pcmattmanFor instance, there's no point having IPC in network drivers
  175. kwolfUnless someone has the idea of moving the TCP/IP stack into CDI
  176. FreakyPenguinWhell what about protocol-stacks in cdi?
  177. pcmattmanIf that were to happen, you would add IPC
  178. kwolfRight. It's going to happen always when you need to stack drivers.
  179. pcmattmanSo I guess it comes down to a) IPC as a necessity in drivers, or b) Add more and more functions to CDI to suit the needs of the communication between drivers
  180. kwolfRight, as I said above. FreakyPenguin, I think it's your turn. ;-)
  181. FreakyPenguinBut I'm just reviewing some nice well commented pascal code. *g*
  182. kwolfMoin XanClic
  183. XanClicGood afternoon
  184. kwolfYou might want to read up the log, we're discussing pretty fundamental questions ;-)
  185. XanClicFirst of all I wouldn't call it "IPC"
  186. XanClicIn a monolithic kernel that's no IPC
  187. kwolfMeh... s/IPC/IDC/g if you all insist on it...
  188. XanClicAnd why not using the cdi_device structure as the destination operand?
  189. XanClicThis structure also tells you what kind of device it is
  190. kwolfHm, it's not a perfect match
  191. kwolfIt contains pointer to the driver and so on which probably don't exist for the caller
  192. XanClicSo you could use an index in an array or something like that, just a handle that can be used to receive more information about the destination driver
  193. kwolfHm, how would receiving a message look like for a driver? A callback function called?
  194. XanClicI think so
  195. XanClicI gives a function pointer to the OS and that one is called upon receiving a message
  196. XanClic*it
  197. kwolfWell then, let's copy the tyndur RPC interface ;-)
  198. XanClicI think it's enough to tell the called driver what driver called it and a pointer to a message (driver-defined format)
  199. kwolfMessages need to consist of at least two different parts to avoid copying things around while constructing the message
  200. kwolfMetadata and payload.