is read() syscall really a primitive?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers is read() syscall really a primitive?
# 1  
Old 10-10-2011
is read() syscall really a primitive?

I saw somewhere that describe read() as a primitive. But when I lean signals, it says the read() may be interrupted by a signal.
My Question:
1, What is the diffence between primitive and reentrant?
2, Is read() a primitive or reentrant?
3, Are all system calls primitive or reentrant?
# 2  
Old 10-10-2011
I think -
You want the word atomic - that means the operation completes before any interrupt can be delivered, like a signal.

Primitive does not mean a call cannot be interrupted by some type of interrupt or signal.
It does mean that they are syscalls, which are direct calls with a defined entry point into the kernel. And they are part of kernel code.

Reentrant has only a little to do with the above. You can write a reentrant function yourself in C.

Reentrant means a function call can be interrupted in the middle of its execution and then safely called again ("re-entered") before its previous invocations complete executing. This is common in threads. In other words a function is reentrant when it can be interrupted anywhere in the middle and then resumed much later - and it always completes correctly even if another instance of the function is started before the old one completes. Being "paused" while another thread runs does not break it.

Any function like localtime that creates a variable in memory that can be overwritten by a subsequent call to the same function is not reentrant.

strtok is notoriously non-reentrant, so a lot of systems have strtok_r. The "_r" terminating characters are a defacto standard for saying this is a "reentrant" function.
# 3  
Old 10-10-2011
But what operations in linux is atomic? Can a primitive be reentrant?

Last edited by vistastar; 10-11-2011 at 01:33 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Download file with socket syscall

Hello to all I want download a file in osx intel 64 with NASM , I want to use socket syscall This is part of my code section .data command db "GET /test/2.gif HTTP/1.1\r\nHost: 10.1.1.187\r\n\r\n", 0 ; url db "http://172.16.207.153/test/2.gif", 0 global main... (1 Reply)
Discussion started by: recher.jack
1 Replies

2. Red Hat

Adding our system call Fedora 18 -new syscall

Hi, I wanna add my own system call to Fedora 18 kernel 3.8.2. From kernel 3.3 I heard there is a new system to add system calls. So where i can find a guides ? I wanna print this text: "Hello world!" in terminal, not dmesg. (4 Replies)
Discussion started by: googz
4 Replies

3. UNIX for Advanced & Expert Users

Process on CPU inside syscall

Hello Experts, If a Solaris process is calling some syscall, and right now execution is inside syscall doing only CPU work, for example the inside simplest times syscall, -> app_func => times << we are here now, we have entered in the times, but not exited yet <= times <- app_func... (9 Replies)
Discussion started by: sant
9 Replies

4. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

5. Shell Programming and Scripting

Read Embedded Newline characters with read (builtin) in KSH93

Hi Guys, Happy New Year to you all! I have a requirement to read an embedded new-line using KSH's read builtin. Here is what I am trying to do: run_sql "select guestid, address, email from guest" | while read id addr email do ## Biz logic goes here done I can take care of any... (6 Replies)
Discussion started by: a_programmer
6 Replies

6. UNIX for Advanced & Expert Users

how to distinguish entry/exit of a syscall when using ptrace?

Hi all, I am using ptrace to keep track of clone syscalls in a program. However, I found that the traced syscall cant be paired. for example, there are some syscalls that have entry, but without exit showing up in the traced sequences. So, is there anyway to distinguish the entry and exit of a... (0 Replies)
Discussion started by: tristartom
0 Replies

7. Programming

Fork syscall and related issues

Hi all, i just started started learning system programming and want to pursue a career in the sys prog area. below is the program that use a fork() call. i read in one of the tutorials that parent process and child process uses different address spaces and runs concurrently. that meas each... (2 Replies)
Discussion started by: MrUser
2 Replies

8. Programming

recv syscall for socket programming

I have a question regarding the recv syscall. Suppose I have a client/server and the following exchange of message took place: Client --> Server using multiple send syscalls one after another immediately: send "Packet1" send "Packet2" send "Packet3" Server receives in the... (2 Replies)
Discussion started by: heljy
2 Replies

9. Programming

Conversion of Hexa Value in String From to Primitive Hexavalue.

Hi, In My Program I have HEXA value in a string array as below : char hexa="0xabcd1234"; //This is how I'm getting source data. Actaully I want this hexa value to be decremented with -1 and store it in another string as "0xabcd1234". Can any body help me how to do that..? I... (1 Reply)
Discussion started by: S.Vishwanath
1 Replies
Login or Register to Ask a Question