memset and atomic_set difference

I am new to learning C and C kernel programming, so please excuse me if the below question is not properly related.

I have seen use of both memset for initializing a value for a certain memory location such as below

iscsitarget-1.4.20.2/usr/sha1.c:    memset(p, 0, padding);
iscsitarget-1.4.20.2/usr/sha1.c:    memset(ctx, 0, sizeof(*ctx));
iscsitarget-1.4.20.2/usr/session.c: memset(session, 0, sizeof(*session));
iscsitarget-1.4.20.2/usr/session.c: memset(&info, 0x0, sizeof(info));
iscsitarget-1.4.20.2/usr/event.c:   memset(&msg, 0, sizeof(msg));
iscsitarget-1.4.20.2/usr/event.c:   memset(&msg, 0, sizeof(msg));

and recently I came across atomic_set, which again initializes a memory location with certain value such as

atomic_set(&tio_work->error, error);

So My question is

What is the difference between the two (memset and atomic_set)? Are they related?


Source: New Questions

Leave a Reply