f



Calling library functions in Linux kernel code

Hi,
I have a few queries about calling library functions in Linux
Kernel(module) code.

What are the disadvantages of using printf instead of printk in kernel
code ?
I have also heard that it is unwise to use standard library functions
in the kernel but was unable to understand why.

Can someone please explain the reason for the same ?

Thanks
Linny
0
linvin333 (14)
7/20/2010 9:43:57 AM
comp.unix.programmer 10848 articles. 0 followers. kokososo56 (350) is leader. Post Follow

1 Replies
416 Views

Similar Articles

[PageSpeed] 44

Linny <linvin333@gmail.com> wrote:
> I have a few queries about calling library functions in Linux
> Kernel(module) code.

> What are the disadvantages of using printf instead of printk in kernel
> code ?

The disadvantage is rather simple: you can't use libraries in
the kernel or in modules code. The kernel isn't a normal program
that would get loaded at some time, including libraries, instead
it's what get used in the end to load other programs and libraries.
Moreover, you really don't want to have potentially buggy or
even malicious code from libraries getting loaded into the kernel
indiscriminately - even a small bug might bring the whole system
down instead of just one of hundreds of programs running at the
same time!

> I have also heard that it is unwise to use standard library functions
> in the kernel but was unable to understand why.

Again, the simple reason is that the standard library isn't
available at all in the kernel. All you've got is what's in
the kernel. You simply have to make do with the functions
the kernel supplies, e.g. with printk() instead of printf().
They are normally somewhat restricted to what you get for
normal user-land programs since most of the functionality
isn't needede in th kernel and only would bloat its size. E.g.
since there are no loating point numbers used in the kernel,
what would having function for printing that can deal with
floating point values be good for? What good would be functions
for opening files for when the kernel itself is needed by these
functions for doing the "opening" etc.? 

                                Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de
0
jt68 (1149)
7/20/2010 11:36:01 AM
Reply:

Similar Artilces:

[Simulink, S-functions] Calling Lapack++ library from a library called by a S-function
Hello fellow Simulink users, I am developing some C++ S-functions which call an external C++ library for physical computations. Library exports match the principal methods used by the runtime environment : (excerpt from the library header file :) __declspec( dllexport ) static MyPhisicalBlock* create( void ) ; __declspec( dllexport ) void set_parameters( double* foo, double* bar ) ; __declspec( dllexport ) void outputs( const double* const in1, double* out1, double* out2r ) ; __declspec( dllexport ) void derivatives( c...

calling matlab code in labview 5 using call library function
hai i have a problem........... i want to call matlab code through call library function or cal interface node and execute it in my labview 5.but as i configer the dll. file in my CLF, it shows error saying function not found in library. i want brief explanation of how to create dll.in matlab and how to call it in labview5 CLF.can anybody help me? divya shetty. :?: ...

call library function node: function not found in library
I'm using Labview 6.1 and Windows XP.&nbsp; I am trying to&nbsp;open some code, but it opens up with a broken arrow.&nbsp; The error is Call Library Function Node:function not found in library.&nbsp; Tried to configure the node, but no change.&nbsp; Moved the DLLs to various directories (keeping them together) but again no change.&nbsp; &nbsp; This code has been compiled and is working fine.&nbsp; I'm just trying to run the source code to&nbsp;make some modifications.&nbsp; Any suggestions?&nbsp; &nbsp; Thanks &nbsp; CarlosV Hi Car...

Exception occured within the external code called by a Call Library Function Node with DAQmx Start Task.v
Exception occured within the external code called by a Call Library Function Node with DAQmx Start Task.vi I have&nbsp;recieved the error that is shown in the attached document.&nbsp; Can anyone give me a hint as to what I may need to do to fix this?&nbsp; It occurs at the same point during the software run every time.&nbsp; The code is also attached.&nbsp; The error occurs in the DAQmx Start Task.vi.&nbsp; the error occurs when the counter reaches approximately 6000 (3000 on the front panel).&nbsp; I am unsure if this is just a coincidence or actually is linked to ...

call functions in static libraries from Fortran code?
Hello all, I have next problem: from the fortran program need to call some C code, compiled in static libraries. I heard about appending underscores to functions in C, but I haven't C sources of theese functions - just a .lib and .h files. So every time I try to compile my program, I receive "unresolved" errors. Do I need to create some wrappers in C like: void cfun_(.........) { //call here function in static library and send results to fortran } - or there exists another way for that (something like translations .h files from c to fortran etc.)? Thanks for all answers (excu...

LabView 6.1 crashes when function in dll is called using call library function
I am writing a LabView application to obtain data from the network using a = DLL written in C.<br>DLL Function:<br>IMPORT_FUNCTION int WINAPI WvListBeds= (const TCHAR *pServerName, const TCHAR *pUserName, const TCHAR *pPassword, = WV_BED_LIST *pBedList, int *pNumberOfBeds) ;<br><br>typedef struct {<br> = TCHAR PatientName [WV_PATIENT_NAME_SIZE] ;<br> TCHAR = PatientID [WV_PATIENT_ID_SIZE] ;<br> TCHAR BedLabel = [WV_BED_LABEL_SIZE];<br> TCHAR CareUnit [WV_CARE_UNIT_= SIZE];<br&...

Is it possible to call functions in a .a static library file? (Unix)
The External Code manual indicates that you can call functions in .so (shared library) files under Unix. Can we also call functions in .a files? I've tried this under Linux, and I always seem to get a "function not found in library" error. Rich_123 wrote: > The External Code manual indicates that you can call functions in .so > (shared library) files under Unix. Can we also call functions in .a > files? > I've tried this under Linux, and I always seem to get a "function not > found in library" error. No you can't do that. Static library files a...

calling my custom function same as library function
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with the declaration for the C library function (stdlib.h in this case) then define/declare my own function with the same name, am I safe? It seems to work on my compiler, but I wonder if this is portable or even acceptable? thx In article <1109555739.136783.312850@l41g2000cwc.googlegroups.com>, Deniz Bahar <deniz.bahar@gmail.com> wrote: >Hi, > >I would like to call one of my ...

Unix/Linux/Perl Tool to determine if function is defined but not called ?
Is there a tool to determine whether a function is defined but not being called in a program?The program can be in any language(C/Perl/Unix)..I studied the nm tool that does the profiling of the object file but that gives all the functions that are defined (whether or not they are called in the file)... On 2006-03-17, bakul.joshi@gmail.com <bakul.joshi@gmail.com> wrote: > Is there a tool to determine whether a function is defined but not > being called in a program?The program can be in any > language(C/Perl/Unix)..I studied the nm tool that does the profiling of > the obje...

Easiest way to write Linux kernel code: cut and paste from Unix
"Yes, it does appear that in this case code was copied into Linux from older Unix versions." http://www.catb.org/~esr/writings/smoking-fizzle.html DFS wrote: > "Yes, it does appear that in this case code was copied into Linux from > older Unix versions." > > http://www.catb.org/~esr/writings/smoking-fizzle.html The entire concluding paragraph reads... <quote> So, in summary, SCO is right where it doesn't matter and wrong where it does. Yes, it does appear that in this case code was copied into Linux from older Unix versions. But because the re...

This function has an onClick event that calls a function that calls This function
The title says it all. The nextmon() and prevmon() functions are listed afterward, since they call fDrawCal().I'm sure you see the problem...prevmon() is not defined prior to being mentioned in the onClick event. But what's the solution? Here's the structure that I have now: function fDrawCal(iMonth, iYear) { var myMonth; myMonth = fBuildCal(iYear, iMonth); document.write('<table id="calendar" cellspacing="0" cellpadding="0" summary="One month calendar">'); document.write('<caption><a onClick="prevmon()"...

accessing errno in CFM code of a MACH-O. function call (Apple's sample code "Call Mach-O Framework")
Hi. I'm using Apple's sample code "Call Mach-O Framework", to access I/O Kit function calls (open(), read(), write()). I've been using the function pointer method. It's been working fine for months, and what simple error handling I've needed I've been able to handle with the return values of the function calls. Now I need to add a more elaborate error handling scheme which requires that I know the value of errno. To my suprise, errno is always zero, even after a function call returns an error. I'm guessing that the real errno is in the Mach-...

System Call Vs Library Function Call
Hi, What are the differences between a system call and library function call except for the fact that the former is executed in kernel mode while the latter in user mode ? ( does this by itself have its own implications ? ) Thanks, Prakash > What are the differences between a system call and library function > call except for the fact that the former is executed in kernel mode > while the latter in user mode ? ( does this by itself have its own > implications ? ) That a little bit like asking "What are the differences between Paris and Kalamazoo except for the fact that ...

Calling external api from call library function
Hello, &nbsp; I have trouble to communicate with a USB device thought call library function. My cypress chip is installed to the ezusb.sys driver and is be able to communicate with the ezusbsys.h file. (Have communicated with my device thought a CIN but the program shown not stable enough)? &nbsp;I have read trough some parts of the ?Using External Code in LabVIEW? which briefly describes how to act: ?Instructions on including a header file xbus.h. Although LabVIEW does not permit you to include such header files, you can open header files and extract information about function ...

Simple C Cross-Platform Shared Code (Non-DLL) Call Library Function Example
I am a graduate student in the fusion science community and am currently de= veloping a transition of our group's data storage system to MDSPlus, the de= facto fusion research archival system. This involves getting LabVIEW to wr= ite results of our various measurements to a MDSPlus data source. The MDSPl= us libraries come pre-packaged with LabVIEW VI's that are essentially wrapp= ers around a Windows DLL. Since our group has LabVIEW running on Windows, M= acintosh, and Linux machines, I am in the process of generating the functio= nal equivalent of a DLL for use with the built-in Cal...

Calling functions from functions from functions ...
Lets say I have a function g(p,x) where x and p are of some defined type. I also have a function NewtonR which I can use like so: x = NewtonR(g,p,x0) There is also another function I want to call ImplicitTrap which can be done as: u = ImplicitTrap(g,p,u0,step,n) This function defines a function of g, and it is this function that I'd like to pass to NewtonR. Can it be done? Basically the code is implementing the implicit trapezoidal rule for numerical integration with the NR solver being used at each step with automatic differentiation being used to handle the differentiation. M...

How override ALL function calls? (Is there a "function call function"?)
I'm trying run a homegrown profiler on some Python code. Rather than apply profiler wrapper to ALL functions by hand.... Is there a low level Python function I can override to modify how ALL functions are called? Chris seberino@spawar.navy.mil wrote: > I'm trying run a homegrown profiler on some Python code. > > Rather than apply profiler wrapper to ALL functions by hand.... > > Is there a low level Python function I can override to modify > > how ALL functions are called? Yes, please take a look at sys.setprofile(). Regards, Martin On 31 Jul 2005 12:01...

DLLs and Call Library Function/Library Name or Path
We are using functions from a DLL to implement Call Library Function Nodes. In the Call Library Function dialog, Library name or path box, we have been putting the complete path to the DLL. If instead we just put the name of the DLL, will the program follow the normal Windows convention to search for the DLL, that is, first in the current directory, then in the %System Root%, then...? > We are using functions from a DLL to implement Call Library Function > Nodes. In the Call Library Function dialog, Library name or path box, > we have been putting the complete path to the DLL. If ins...

How to call a C pointer from call library function node
I have a client/server application which the client I am trying to develop using Labview.&nbsp; When I use to communicate the server and the client using the&nbsp;program provided by the manufacter, the system works perfectly. &nbsp; Now, I am trying to develop a system using labview, because I need to get another things. &nbsp; I have the DLL provided by the manufacter and the .h too, so I can check the functions parameters. One of these functions needs to be called using a struct element. Probably, the function's&nbsp;DLL instantiates the elements of this struct.&...

Mach-O library calling function from carbon library
I have created a Mach-O library in CW 8.3/Mac OS 10.3.4 that calls some functions exported from a carbonised shared library (also created in CW 8.3) After failure of directly dropping the carbon library inside the mach-o project I saw in the groups that GetDiskFragment/FindSymbol can do the job. I used "CodeFragments.h" and "MixedMode.h". Now, the project compiles ok, but the linker complains about "undefined symbols" for DisposePtr, FSMAkeFSSpec, NewPtr, GetDiskFragment, FindSymbol and so on. What is the required library I need to put into the project? So far I have only included MSL_All_Mach-O.lib, CarbonLib is not accepted. Thanx Byron In article <drt4br$2he7$1@ulysses.noc.ntua.gr>, "bg-greece" <byron@mail.gr> wrote: > I have created a Mach-O library in CW 8.3/Mac OS 10.3.4 that calls some > functions exported from a carbonised shared library (also created in CW 8.3) > After failure of directly dropping the carbon library inside the mach-o > project I saw in the groups that GetDiskFragment/FindSymbol can do the job. > I used "CodeFragments.h" and "MixedMode.h". > > Now, the project compiles ok, but the linker complains about "undefined > symbols" for DisposePtr, FSMAkeFSSpec, NewPtr, GetDiskFragment, FindSymbol > and so on. What is the required library I need to put into the project? So > far I have only included MSL...

Call By Reference Node + Call library function node
Hello, &nbsp; I have multiple subVI's that load a DLL with a Call library function node. Each of these subVI's use a different function of the dll.&nbsp;I only wish to load&nbsp;them when i actually need them. To do so Im using a Call By Reference Node. This works for all of them except one. For some reason it only works if&nbsp;I actually have the SubVI opened in labview. Im not getting any usefull errorcodes. And i can't see what is going wrong in the subVI as it does work when it is open. The dll im using is for a <a href="http://www.meinberg.de/english/p...

Linux Syscalls, POSIX Functions and other generic Library Functions.
Hi all. I have a question about the API that the GNU/Linux distributions provide to the application software writers. I hope to be able to explain well the subject of the question with the help of my poor English. The Linux Programmer's Manual, commonly installed with every GNU/Linux distribution, contains sections 2, 3 and P that respectively are the System Calls, the Library Functions and the POSIX manuals. I know that many GNU/LibC functions are only wrappers that directly invoke hidden kernel API (syscalls) by means of some assembly statements and the INT H80 instruction...

ERROR: external code called by a Call Library Fonction Node
Hello, I'm using LABVIEW 8.2 for developing and also installed the Run-Time Engine 8.2 from the NI website on one of the laptops that use our program as a stand-alone application. I receive the following error while trying to measure the frequency of a signal in the stand-alone version:An exception occurred within the external code called by a Call Library Fonction Node. This might have corrupted LABVIEW's memory. Save any work to a new location and restart LABVIEW. VI "Compteur d'impulsions v1.10.vi" was stopped at node "" at a call to "DAQmx Create AI Cha...

calling vi continues execution before the call library function returns
In my app one of the VI makes a function call using a "Call library function" node. Then the VI goes on to execute the next frame in my sequence diagram even before the "library function" returned. &nbsp; The Call library function is configured as "Reentrant" with "C" calling convention. The VI executes in "Standard" priority. &nbsp; The library function controls a GPIB instrument and returns when the control process reaches "stability". I can visually see the control process working fine but my return value from the function...

Web resources about - Calling library functions in Linux kernel code - comp.unix.programmer

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

Eating chocolate 'improves brain function' - study
... news for those with a sweet tooth - a recent study has found that regular chocolate consumption is associated with better cognitive function. ...

Using Functions to Make Better Abstractions
... (code that is tightly coupled to its own implementation details). I was wrong. I was wrong because I had an incomplete understanding of functions. ...

Cisco launches new network functions virtualization infrastructure solution to help service providers ...
Al-Bawaba Cisco launches new network functions virtualization infrastructure solution to help service providers run network ... Al-Bawaba ...

Google Maps for iOS adds detour function, 3D touch support
Google has extended its pit-stop feature the ability to find places to stop off on journeys to iPhone and iPad users with the release of Google ...

Yahoo Begins Grim Job of Closing Functions, Laying Off Staff
Yahoo Food is closing, and other digital magazines on tech, travel and beauty are also scheduled for closing or major cutbacks.

Don’t tase me, bro: Study shows being shocked by a Taser disrupts brain function
Researchers at Drexel shot a bunch of college students with 50,000 volts. The result? Short-term declines in cognitive function comparable with ...

Engineers 3D Print Tissue That Mimics How The Human Liver Functions
Engineers say they have 3D printed life-like liver tissue that could be a new platform in the lab to test the efficacy of drugs saving pharmaceutical ...

A 3D Printed Jet Engine Appears to Function
... jet engine . You may remember seeing a 3D printed jet engine grace our front page back in October. That one was beautiful didn’t function . ...

‘World Of Warcraft’ Alpha Removes Gold From Garrison Missions, Water Striders No Longer Function Everywhere ...
... build deploying soon to the alpha server, garrison missions no longer reward gold and the water-walking Water Strider mounts no longer function ...

Resources last updated: 3/7/2016 7:44:40 PM