Solved

lock_kernel() ...

Posted on 2001-08-28
5
885 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 21

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.

738 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