Solved

lock_kernel() ...

Posted on 2001-08-28
5
874 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 117
mapAB Challlenge 35 160
unix example issues 18 100
Problem to App source 6 75
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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