Solved

lock_kernel() ...

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 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.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

14 Experts available now in Live!

Get 1:1 Help Now