What Happens to a PCB When the State of a Process Changes

Bhanu Priya
Updated on 01-Dec-2021 11:25:54

1K+ Views

Process control block (PCB) is used by the operating system to store different information about the process including process state, registers, program counter, registers etc. It plays an important role when a context switching happens (the current process is pre-empted by another process with higher priority).The important information stored in PCB includes the following −Process Number (PID) − Used to uniquely identify each process.Program counter − It stores the address of the next instruction which is to be executed.Register Info − Includes different CPU registers such as base, accumulators and general purpose register.State − State in the life cycle of ... Read More

Privileged and Non-Privileged Instructions in Operating System

Bhanu Priya
Updated on 01-Dec-2021 11:20:54

4K+ Views

Let us understand the privileged instructions in an operating system.Privileged instructionsThese are called machine level instructions that are executed when the processor is in privileged mode.The examples include the following −Shut down the systemChange the contents of a control register.Jump into kernel code.Sending commands to I/O devices.The processor is said to be in privileged mode when the functions in the OS kernel are executing.Suppose an attempt is made to execute a privileged instruction in non-privileged mode which causes a run-time error.Generally the user mode of the operating system is called non-privileged mode and kernel mode of the operating system is ... Read More

Five Process States in the Linux Kernel

Bhanu Priya
Updated on 01-Dec-2021 11:10:45

1K+ Views

The five process states in the Linux kernel are as follows −Running − This is a state where a process is either in running or ready to run. It is the most active state of all. In this state, the process is getting system resources.Interruptible − This state is a blocked state of a process which waits for an event or a particular time slot.Uninterruptible − It is also a blocked state and it has a timeout value before going to sleep. It will awake when the timeout value sets off.Stopped − Once the process is completed, this state occurs ... Read More

Different Types of Process States and Queues

Bhanu Priya
Updated on 01-Dec-2021 11:08:48

2K+ Views

Let us begin by understanding the types of process states.Types of Process StatesThere are different types of Process States which are as follows −New − The process is about to be created in this state but not yet created, it is the program which is present in secondary memory that will be picked up by OS to create the process.Ready − The process enters the ready state after the creation of a process that means the process is loaded into the main memory.Running − The process is chosen by the CPU for instructions and the executions within the process and ... Read More

While Loop in Lua Programming

Mukul Latiyan
Updated on 01-Dec-2021 10:58:07

676 Views

A while loop is an indefinite loop that can be modified to run for a finite number of iterations based on the condition we provide.In Lua, the while condition is tested first. If the condition turns out to be false, then the loop ends, otherwise, Lua executes the body of the loop and repeats the process.Syntaxwhile( condition ){ // do this }ExampleConsider the example shown below −a = {1, 2, 3, 4, 5} local i = 1 while a[i] do print(a[i]) i = i + 1 endOutput1 2 3 4 5It ... Read More

Variable Number of Arguments in Lua Programming

Mukul Latiyan
Updated on 01-Dec-2021 10:50:06

4K+ Views

There are functions in Lua that accept a variable number of arguments. These are very helpful in cases where we want to run the same function with many different arguments that might vary in length. So, instead of creating a different function, we pass them in a variable arguments fashion.Syntaxfunction add(...) -- function code endIt should be noted that the three dots (...) in the parameter list indicate that the function has a variable number of arguments. Whenever this function will be called, all its arguments will be collected in a single table, which the function addresses ... Read More

Table Type in Lua Programming

Mukul Latiyan
Updated on 01-Dec-2021 10:46:45

2K+ Views

A table is a data type in Lua, which is used to implement associative arrays. These associative arrays can be used to implement different data structures like queues, maps, lists, etc.An associative array in Lua is an array that can be indexed not only with numbers, but also with strings or any other value of the language, except nil.Tables in Lua don't have any fixed size, and we can insert as many elements as we want in them, dynamically.Tables in Lua are neither values nor variables; they are objects.We can create tables by means of a constructor expression, which in ... Read More

Return Statement in Lua Programming

Mukul Latiyan
Updated on 01-Dec-2021 10:44:34

5K+ Views

There are certain cases where we want to return a value from a given function so that we can use it later. These return values make use of a return keyword which in turn allows a function to return values.There is an implicit return at the end of any function, so you do not need to use one if your function ends naturally, without returning any value.It should be noted that the return statement is optional; if not specified, the function returns nil.Also, only one return statement is allowed in a function.Syntaxreturn expression/valueNow let’s consider an example where we would ... Read More

Numeric For Loop in Lua Programming

Mukul Latiyan
Updated on 01-Dec-2021 10:42:21

1K+ Views

In Lua, there are two types of for loops − the numeric for and the generic for.SyntaxThe numeric for uses the following syntax −for var=exp1, exp2, exp3 do something endIt should be noted that we can write exp1, exp2, exp3 at the same time or we can omit one of them, and the numeric loop will not result in a compile error, though its functionality will change.ExampleLet’s consider a simple variation of a numeric for loop, where we will try to print numbers from 1 to 10.Consider the example shown below −for i = 1, 10 do ... Read More

Named Arguments in Lua Programming

Mukul Latiyan
Updated on 01-Dec-2021 10:36:33

1K+ Views

We know that when we pass arguments to a function in any programming language, they are matched against a parameter. The first argument’s value will be stored in the first parameter, the second argument’s value will be stored in the second parameter, and so on.ExampleConsider the example shown below −local function A(name, age, hobby) print(name .. " is " .. age .. " years old and likes " .. hobby) end A("Mukul", 24, "eating")OutputMukul is 24 years old and likes eating The above example works fine if we carefully pass the same argument as for the ... Read More

Advertisements