Solved

lock_kernel() ...

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

813 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

12 Experts available now in Live!

Get 1:1 Help Now