A

@Adarsh222

imp

C
3 years ago
Task - Its an unit of execution(function) for a program these are sheduled by RTOS on diff diff priority order What is a critical section in an RTOS and how is it protected? A critical section is a part of code in an RTOS where a shared resource is accessed, and it must be protected to prevent concurrent access by multiple tasks. It is protected using mechanisms such as semaphores or mutexes to ensure that only one task can access the critical section at a time. Semaphore - syncronisation mec

Typecasting

C
3 years ago
/* Typecasting in C allows you to convert a value of one data type to another data type. Here's an example program that demonstrates typecasting: */ #include <stdio.h> int main() { double x = 3.14159; int y = (int) x; // Typecasting x from double to int

Operators

C
3 years ago
#include <stdio.h> #include <stdbool.h> int main() { // Arithmetic Operators int x = 10; int y = 5; int sum = x + y; // Addition int difference = x - y; // Subtraction int product = x * y; // Multiplication

Advance is we cannot take size from user and cannot determine size

C
3 years ago
#include <stdio.h> #include <stdlib.h> int main() { int capacity = 5; // initial capacity int size = 0; // current number of elements int *arr = malloc(sizeof(int) * capacity); int num; while (scanf("%d", &num) == 1) { // read integers until end of input

doubly linked list

C
3 years ago
#include <stdio.h> #include <stdlib.h> struct Node { int data; struct Node *prev; struct Node *next; }; void insertAtEnd(struct Node **head, int value) {

struct size

C
3 years ago
struct Person { char name[20]; int age; float height; };//int32_t Example 1: c Copy code

what is dead lock

C
3 years ago
A deadlock is a situation that can occur in a computer system where two or more processes are blocked, unable to proceed because they are waiting for each other to release resources. Imagine two people are each holding a key to a different door, but they need to go through both doors to get where they want to go. Person A has the key to door 1 and is waiting for person B to unlock door 2. Person B, meanwhile, has the key to door 2 and is waiting for person A to unlock door 1. Neither person ca

Rtos vs Linux

C
3 years ago
RTOS (Real-Time Operating System) and Linux are two different types of operating systems with different characteristics and use cases. Here are some key differences between the two: Real-time performance: RTOS is designed to provide deterministic, real-time performance, where the system responds to events within a guaranteed time frame. Linux, on the other hand, is a general-purpose operating system and may not provide the same level of real-time performance. Footprint: RTOS is des

what is the normal boot sequence frm powerup of your rtos or linux

C
3 years ago
The normal boot sequence for an RTOS (Real-Time Operating System) or Linux can vary depending on the specific system and configuration, but here is a general overview of the process: Power on: When the system is powered on, the hardware initializes and performs a power-on self-test (POST) to check for any hardware issues. Boot loader: The boot loader is the first software program that runs after the hardware initialization. It loads the operating system kernel into memory and prepa

how a system works in linux

C
3 years ago
A Linux system is made up of several components that work together to provide a functional and usable operating system. Here is a brief overview of some of the key components and how they work: Kernel: The Linux kernel is the core of the operating system. It manages system resources such as the CPU, memory, and devices like disks and network interfaces. It also provides system calls that allow applications to interact with the kernel. Shell: The shell is a command-line interface th

Mutex vs Semaphore

C
3 years ago
Both mutexes and semaphores are mechanisms used to coordinate access to shared resources in a concurrent programming environment. A mutex (short for mutual exclusion) is a synchronization object used to ensure that only one thread at a time executes a critical section of code. In other words, a mutex is used to protect a shared resource from simultaneous access by multiple threads. When a thread acquires a mutex, it gains exclusive access to the shared resource, and all other thread

Process vs Thread

C
3 years ago
In simple terms, a process is like a program running on your computer, while a thread is like a task within that program. A process has its own memory space, system resources, and can run independently of other processes. Each process can have multiple threads, and each thread can perform a specific task within the process. Threads, on the other hand, share the memory and resources of the process they belong to. Multiple threads can run simultaneously within a process, allowing for p

isspace() ispuncht()

C
3 years ago
#include <stdio.h> #include <ctype.h> int main() { char c = ' '; if (isspace(c)) { printf("The character is a whitespace character.\n"); } else { printf("The character is not a whitespace character.\n"); }

static keyword

C
3 years ago
#include <stdio.h> void increment() { static int count = 0; count++; printf("Count is %d\n", count); } void use_increment() { increment();

volatile keyword

C
3 years ago
#include <stdio.h> int main() { volatile int x = 10; while (x == 10) { printf("x is %d\n", x); } return 0; }

Find substring: You may be asked to write code to find the first occurrence of a given substring

C
3 years ago
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(){ char *str = NULL; char *sub = NULL; size_t lent = 256;

imp remove the white space between char

C
3 years ago
#include <stdio.h> #include <string.h> int main() { char a[20]; scanf("%[^\n]",a);//note if(scanf("%d",a)==1) will not work for array int len = strlen(a); for(int i;i<len-1;i++){ if(a[i]==' '){// if only i then only 1 shifts and others remain constant

IMP reverses the words in a sentence

C
3 years ago
#include<stdio.h> #include<string.h> #include<stdlib.h> int main(){ char *str=NULL; size_t length = 0; if(getline(&str,&length,stdin) == -1){//only use for till /n new line input printf("no input");

IMP Write a function that takes a string as input and returns the reverse of that string

C
3 years ago
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ char a[] = "adarsh"; int len = sizeof(a)/sizeof(a[0]) - 1; // subtract 1 to exclude null terminator printf("%d\n", len);//scanf only no getline /*IMP we need to exclode '\0' for reversing so only 6 char "adarsh"*/

imp Counting Set Bits

C
3 years ago
#include <stdio.h> int main(){ int a = 10; //1010 a = a | (1<<0); printf("%d\n",a); a = a & ~(1<<0); printf("%d\n",a);