* Linked lists for userspace programs in Linux @ 2014-06-13 18:38 Chandrasekaran Sivakumar 2014-06-16 3:24 ` Valdis.Kletnieks at vt.edu 0 siblings, 1 reply; 5+ messages in thread From: Chandrasekaran Sivakumar @ 2014-06-13 18:38 UTC (permalink / raw) To: kernelnewbies Hi all, I wanted to use linked lists in one of my userspace programs in Linux. I tried two methods, 1. I used the modified version of list implementation given in http://isis.poly.edu/kulesh/stuff/src/klist/list.h for my userspace program. But when I compiled the kernel, there were errors showing 'redefinition of struct', 'conflicting types' etc. 2. When I tried to use list.h as such without any modifications, linked list functions in my userspace program were not identified by the compiler and displayed as undefined. Would it be okay to modify the variable/function names in a copy of list.h and use it in the userspace program ? Please advise. Thank you. Regards, chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140614/a41f7792/attachment.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Linked lists for userspace programs in Linux 2014-06-13 18:38 Linked lists for userspace programs in Linux Chandrasekaran Sivakumar @ 2014-06-16 3:24 ` Valdis.Kletnieks at vt.edu 2014-06-16 8:13 ` Robert P. J. Day 2014-06-16 13:35 ` Chandrasekaran Sivakumar 0 siblings, 2 replies; 5+ messages in thread From: Valdis.Kletnieks at vt.edu @ 2014-06-16 3:24 UTC (permalink / raw) To: kernelnewbies On Sat, 14 Jun 2014 02:38:19 +0800, Chandrasekaran Sivakumar said: > I wanted to use linked lists in one of my userspace programs in Linux. Userspace. Remember that word. > 1. I used the modified version of list implementation given in > http://isis.poly.edu/kulesh/stuff/src/klist/list.h for my userspace > program. But when I compiled the kernel, there were errors showing > 'redefinition of struct', 'conflicting types' etc. You're recompiling the kernel for what reason? You seem to be confused regarding kernel space versus userspace programming... > 2. When I tried to use list.h as such without any modifications, linked > list functions in my userspace program were not identified by the compiler > and displayed as undefined. This sounds like you need an introductory C class. Did you remember to #include them? Oh, by the way, keep in mind that the Linux kernel "linked list" is actually a circularly linked list - as a result, treating it as a normal linked list (particularly when checking for empty list or end-of-list) is likely to result in hilarity and hijinks for all... > Would it be okay to modify the variable/function names in a copy of list.h > and use it in the userspace program ? You'd probably be better off learning basic data structures well enough to write your own implementation. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 848 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140615/ef9bf990/attachment.bin ^ permalink raw reply [flat|nested] 5+ messages in thread
* Linked lists for userspace programs in Linux 2014-06-16 3:24 ` Valdis.Kletnieks at vt.edu @ 2014-06-16 8:13 ` Robert P. J. Day 2014-06-16 13:35 ` Chandrasekaran Sivakumar 1 sibling, 0 replies; 5+ messages in thread From: Robert P. J. Day @ 2014-06-16 8:13 UTC (permalink / raw) To: kernelnewbies On Sun, 15 Jun 2014, Valdis.Kletnieks at vt.edu wrote: > Oh, by the way, keep in mind that the Linux kernel "linked list" is > actually a circularly linked list - as a result, treating it as a > normal linked list (particularly when checking for empty list or > end-of-list) is likely to result in hilarity and hijinks for all... once upon a time, i wrote a piece on how kernel linked lists work, i think it's still accurate. http://crashcourse.ca/introduction-linux-kernel-programming/intermission-lets-talk-about-linked-lists-and-containerof-free rday -- ======================================================================== Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ======================================================================== ^ permalink raw reply [flat|nested] 5+ messages in thread
* Linked lists for userspace programs in Linux 2014-06-16 3:24 ` Valdis.Kletnieks at vt.edu 2014-06-16 8:13 ` Robert P. J. Day @ 2014-06-16 13:35 ` Chandrasekaran Sivakumar 2014-06-16 16:01 ` Valdis.Kletnieks at vt.edu 1 sibling, 1 reply; 5+ messages in thread From: Chandrasekaran Sivakumar @ 2014-06-16 13:35 UTC (permalink / raw) To: kernelnewbies Hi, Apologies from me. I didn't explain my problem properly. I am working on modifying the linux kernel's scheduler framework to include support for real-time algorithms. In order to give user inputs such as number of tasks, their execution cost, period, deadline etc, I am creating an userspace program. Then this program would transfer control to the kernel to perform system calls for creation and execution of tasks. Thats why I had to recompile the kernel. I had planned to use linked list to contain the multiple execution cost values in each task (for a mixed criticality task system). As the control is transferred to the kernel, the linked list should be accessed from the kernel side also. As you had suggested, I had written my own implementation of linked lists. Please advise me on how to make this implementation (contained in a header file) common to both kernel and userspace ? Thank you for your time. Regards, chandru On Mon, Jun 16, 2014 at 11:24 AM, <Valdis.Kletnieks@vt.edu> wrote: > On Sat, 14 Jun 2014 02:38:19 +0800, Chandrasekaran Sivakumar said: > > > I wanted to use linked lists in one of my userspace programs in Linux. > > Userspace. Remember that word. > > > 1. I used the modified version of list implementation given in > > http://isis.poly.edu/kulesh/stuff/src/klist/list.h for my userspace > > program. But when I compiled the kernel, there were errors showing > > 'redefinition of struct', 'conflicting types' etc. > > You're recompiling the kernel for what reason? You seem to be confused > regarding kernel space versus userspace programming... > > > 2. When I tried to use list.h as such without any modifications, linked > > list functions in my userspace program were not identified by the > compiler > > and displayed as undefined. > > This sounds like you need an introductory C class. > Did you remember to #include them? > > Oh, by the way, keep in mind that the Linux kernel "linked list" > is actually a circularly linked list - as a result, treating it as a > normal linked list (particularly when checking for empty list or > end-of-list) > is likely to result in hilarity and hijinks for all... > > > Would it be okay to modify the variable/function names in a copy of > list.h > > and use it in the userspace program ? > > You'd probably be better off learning basic data structures well enough > to write your own implementation. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140616/c687d368/attachment-0001.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Linked lists for userspace programs in Linux 2014-06-16 13:35 ` Chandrasekaran Sivakumar @ 2014-06-16 16:01 ` Valdis.Kletnieks at vt.edu 0 siblings, 0 replies; 5+ messages in thread From: Valdis.Kletnieks at vt.edu @ 2014-06-16 16:01 UTC (permalink / raw) To: kernelnewbies On Mon, 16 Jun 2014 21:35:20 +0800, Chandrasekaran Sivakumar said: > Apologies from me. I didn't explain my problem properly. I am working on > modifying the linux kernel's scheduler framework to include support for > real-time algorithms. In order to give user inputs such as number of tasks, > their execution cost, period, deadline etc, I am creating an userspace > program. Then this program would transfer control to the kernel to perform > system calls for creation and execution of tasks. Nope. Wrong answer. You can't do real-time that way. If the userspace code gets hung in a loop or something, your in-kernel scheduler can get stuck with old/stale information, and as a result incorrectly schedule the next process, causing a realtime window to be totally blown. And if all the userspace code is doing is writing config information for which tasks get what priorities, you should be instead extending the sched_setscheduler() syscall, or possibly adding a /proc/PID/<something> interface. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 848 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140616/ce988ee0/attachment.bin ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-16 16:01 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-06-13 18:38 Linked lists for userspace programs in Linux Chandrasekaran Sivakumar 2014-06-16 3:24 ` Valdis.Kletnieks at vt.edu 2014-06-16 8:13 ` Robert P. J. Day 2014-06-16 13:35 ` Chandrasekaran Sivakumar 2014-06-16 16:01 ` Valdis.Kletnieks at vt.edu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).