Solved

lock_kernel() ...

Posted on 2001-08-28
5
859 Views
Last Modified: 2013-12-26
Hi, I'm Salvatore , from Italy.
My question:
How can i lock a my function from time-sharing-scheduling?
I've tried including smp_lock.h that contain lock_kernel
& unlock_kernel() and calling it.
gcc goals but i think that it does not work.

I'm writing some programs about semaphore and shared memory (exactly for resolving problem of reader's and writer's, producer & consumer).
For debug i use some printf and it happen strange things. Printf is buffered and using a fork i found a father's printf in the system calls of the process created.
(see strace -ff -T -tt exe).
Than i'm writing a function (print2debug()) that lock
the kernel so all state(variables, contest in which printf appear) are ok while execute the debug function.
I thank you for any reply!!! GoodBye from Naples.
0
Comment
Question by:slionetti
5 Comments
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 50 total points
ID: 6437040
First, you can use fflush() to flush the printf buffer.

Meanwhile, the lock_kernel() stuff is probably only for use within the kernel.

I'm guessing this is a homework problem, so you're actually first supposed to write the semaphore stuff yourself.  But if not, see the man pages for semget(), semop() and semctl().
0
 
LVL 1

Expert Comment

by:nhuanvn
ID: 6443254
I don't think that you can lock the kernel in Unix user
space. In some realtime OSs like VxWorks [www.windrivers.com] they provides taskLock() that can
serve your question. You can use semaphores instead in
Unix, but it is of course not strong enough as kernel_lock
feature
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 6444526
You can't lock the kernel in user space.  The include files have both the user- and kernel-space prototypes, though.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 8191570
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by chris_calabrese

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Expert Comment

by:modulo
ID: 8241217
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now