Sponsored Content
Top Forums Programming Why is C/C++ considered low-level languages??? Post 302622637 by Corona688 on Thursday 12th of April 2012 11:26:50 AM
Old 04-12-2012
fopen, fclose, et al are function calls -- they jump your program to a location in memory and execute the code there. If you ran the program in a debugger, you could potentially trace inside these functions and see what they do. They are built for reasons of convenience and portability -- you could build a function which works the same everywhere, for instance, even when the system calls might be slightly different, or add simple functionality like buffers, which is indeed what stdio calls like fwrite are for. It's faster to call putc() 10,000 times to write single chars than to call write() 10,000 times for single chars because putc will just dump it in memory for later.

They certainly can't replace system calls. To write to a file, fwrite() must ultimately call write().

System calls on the other hand are not libraries. They don't jump to the start of an instruction in memory, they pass a message to the operating system, then wait. If you try and trace inside a system call, there's nothing to trace, because your program literally stops running while the system call happens -- the action happens inside the kernel itself, where you can't see.

C is able to freely use raw system calls because it can understand the same data structures the kernel uses for system calls -- the kernel is also C. It compiles it down into raw assembly language like everything else; it becomes the setting of a few registers then something like INT 0x80 to make a software interrupt to inform the kernel you want a system call.

This is difficult for other languages to do natively. Surely they can do INT 0x80, but without the C language itself, it's very difficult to get the data structures right. I've seen some people hardcode system calls in perl and have their code stop working when they move it to a different system, because the data structures changed, but their code didn't. In C, you'd just use the native data structures for wherever you were, and your code wouldn't need to change.
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Low level format?

I want to do a low level format like in windows (C:\format c:) but I don't know how it works in unix or linux.. Can somebody help me ? thnx :) (3 Replies)
Discussion started by: day
3 Replies

2. What is on Your Mind?

Programming languages polyglots: how many languages you know?

Post what languages (including scripting) you know, why and where you think that language is most usable. Also include libraries in which you're really good at (libusb, gtk, qt, etc). assembly? C or C++? perl or python? pascal? bash or csh/tcsh? opengl? gtk or qt? mono? (27 Replies)
Discussion started by: redoubtable
27 Replies

3. Programming

write() issue during a low level hdd access

Hi, I am trying to write zeroes to the hdd using a c program. I don't want to use the dd or ddrescue or any such inbuilt program because of reasons like real time progress, writing custom patterns. (my program is more like an erasure application, but does only zero fill). here are the steps... (35 Replies)
Discussion started by: sponnusa
35 Replies

4. IP Networking

Best reference for understanding low level info on nic cards drivers and functionality

Hi, What is the best reference that gives in detail on nic cards configuration , assigning multiple ip addresses to a single interface, netlink library etc and all basic stuff at this level..? Thanks (2 Replies)
Discussion started by: Gopi Krishna P
2 Replies

5. AIX

High Runqueue (R) LOW CPU LOW I/O Low Network Low memory usage

Hello All I have a system running AIX 61 shared uncapped partition (with 11 physical processors, 24 Virtual 72GB of Memory) . The output from NMON, vmstat show a high run queue (60+) for continous periods of time intervals, but NO paging, relatively low I/o (6000) , CPU % is 40, Low network.... (9 Replies)
Discussion started by: IL-Malti
9 Replies

6. Programming

System calls and C language low-level qualities???

Hi friends, I hope everyone is fine and doing well. I queried in my previous thread about the low-level qualities of C/C++ languages.I really thank you people for explaining, it was really helpful. One more ambiquity that I have in my mind is regarding the unix system calls like open, creat,... (1 Reply)
Discussion started by: gabam
1 Replies

7. Programming

Low level X11 programming

How to use X11 without Xlib not XCB? How draw window directly on low level? I must use anyway window manager like Motif? I have ridden that X11 has server-client architecture, client send via TCP/IP to port 6000 request for primitives and get replies. Where is detailed description of it? In X11... (0 Replies)
Discussion started by: AndrzejB
0 Replies
trace(5)							File Formats Manual							  trace(5)

Name
       trace - system call tracer device

Description
       The  file  is the system call trace device. It supports the following system calls: and The device supports 16 (configurable in as TR_USRS)
       simultaneous users. It uses an 8192-byte buffer for trace records.  The choice of which system calls to trace is done with the system call.
       The  call  is  used for efficient reading of the device.  The call uses an 8192-byte buffer and returns when the buffer is 60% full.  It is
       required that the user use a buffer the same size as the system buffer size defined in as TR_BUFSIZE.  All operations are  defined  in  the
       header file, The calls are:

       --------------------------------
       ioctl	      arg (pointer to)
       --------------------------------
       IOTR_GETOFF    int a
       IOTR_GETON     int a
       IOTR_GETALL    int a
       IOTR_GETPIDS   int a[10]
       IOTR_GETUIDS   int a[10]
       IOTR_GETSYSC   int a[10]
       IOTR_GETPGRP   int a[10]
       IOTR_SETOFF    int a
       IOTR_SETON     int a
       IOTR_SETALL    int a
       IOTR_SETPIDS   int a[10]
       IOTR_SETUIDS   int a[10]
       IOTR_SETSYSC   int a[10]
       IOTR_SETPGRP   int a[10]
       --------------------------------

Examples
       A prototype example (with missing parts):
       char cmd[BUFSIZ],buf[TR_BUFSIZ];
       int pgrp[10],i;
       fd = open("/dev/trace",0);      /* open the device */
       pgrp[0] = dofork(cmd);	       /* fork the command to trace */
       for (i=1;i<TR_PGRP;i++)	       /* dofork sleeps 2 seconds while */
	       pgrp[i] = 0;	       /* we set up to do the trace */
       i = ioctl(fd,IOTR_SETPGRP,pgrp);/* set up for the trace */
       /* select code goes here */
       read(fd,buf,sizeof(buf));

See Also
       trace(1), close(2), ioctl(2), open(2), read(2), select(2)

																	  trace(5)
All times are GMT -4. The time now is 04:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy