prac 3 : deadlock simulation Flashcards

1
Q

library required to create thread

A

<pthread.h>
</pthread.h>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

function to create thread,

A

step 1 : crate variable with thread datatype

ex pthread_t a;

pthread_create( & a , null thread_function, NULL)

  1. &a : adddress of thread
  2. null: default attribute
  3. name of function which contains whatever the thread is supposed to do
  4. null : input to this function. null implies nothing is passed to function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what header file library provides access to system calls and low-level I/O operations

A

include<unistd.h></unistd.h>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

no of parameters to create thread in function and meaning of each

A
  1. &a : adddress of thread
  2. null: thread is going to acquire default attribute given by system
  3. name of function which contains whatever the thread is supposed to do
  4. null : input to this function. null implies nothing is passed to function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to initialize thread :

A

pthread_t thread_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What function is used to wait for thread to finish ?

A

pthread_t a;
pthread_join(a, NULL)

a : the thread for which you want to wait
Null : this parameter tells just in case you want thread to return something, here means we want it to return nothing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what to include while running thread program in terminal

A

gcc prog_name.c -lpthread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do we prototype thread function

A

void * thread_function (void * arg)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to declare variable that is used for locking or unlocking ?

A

pthread_mutex_t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how to initialise variable declared for locking

A

pthread_mutex_init()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

when thread wants to enter critical section what will it acquire to variable

A

pthread_mutex_lock()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

when thread wants to go out of critical section what will it acquire to variable

A

pthread_mutex_unlock()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly