Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-30-2012, 07:07 AM
|
#1
|
|
LQ Newbie
Registered: Apr 2010
Posts: 16
Rep:
|
semaphore usage in user and kernel level
Hi,
I was going through the semaphore's usage in linux and not yet get clear understanding on below things.
1. Is user and kernel level programming in Linux had different semaphore function calls?
2. what is the difference between "#include <linux/semaphore.h>" and "#include <semaphore.h>" files.
3. Can you please let me know where the user(applications) and kernel(modules) concepts differ in terms of programming on Linux.
Thanks in advance.
|
|
|
|
11-09-2012, 10:06 PM
|
#2
|
|
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Squeeze (Fluxbox WM)
Posts: 1,357
|
- In general kernel code cannot make use of any user space code. So while implementations of semaphores in user space simply make use of the operating system API for their implementation (ie, only indirectly using the kernel), inside the kernel code there has to be more direct use of interprocess primitives. The C interfaces could be made to look the same. But the kind of locking you might want to do in the kernel is not quite the same as in user code (so there are different primitives available), there's little attempt made to make them look the same.
- You would normally use <semaphore.h> in your program. The directory /usr/include/linux contains header information that is specific to interfacing with the kernel; it is still designed for user space code, but is not portable. You might need it if you require more specific API support.
- Programming in C for user applications and for the kernel differs because the context is different. In user space, the operating system takes care of process spawning, supports the primitives that the standard C libraries use for all I/O, provides the memory handling and security to ensure the proper separation of user processes, and so on. In monolithic kernel code, you have to be more aware of the context, since the support code you are using is not standard C libraries, but other components of the kernel. In the kernel, you are one level closer to the hardware, and do not enjoy the abstraction of the standard libraries.
Last edited by neonsignal; 11-09-2012 at 10:11 PM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:39 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|