Posts

Showing posts from September, 2021

CROSS COMPILERS

 CROSS COMPILERS: In Embedded System, mostly we develop codes for micro-controllers by using IDLE’s on Desktop or Laptop. So here the Host is our Laptop/Desktop and the Target is Micro-Controller. Before explaining about cross compiling I would like to brief about What is compilation? Compilation is a process to convert our high level or middle level language code (let say C language) to machine understandable code (hex file). Now I am trying to explain about cross compilation… Normally micro-controllers are differ in their architectures. Our Desktop and Laptop having 32/64 bit Processors. So if you compile one code from your 64 bit Laptop using normal compiler (let say GCC compiler for C language), that will generate hex file ( compiled output ) which is understandable only for that 64 bit processor. That means you can execute your code only in your Laptop/Desktop. Here the Host and Target are same. So no need to use cross compilers. Let us think about another scenario like, you w...

ESD (SHARED DATA)

  WHAT IS SHARED DATA? some data is common to different threads or process eg: Time, which is continuously updated by the process, is also used by display process in a system. Port input data , which is received by one process and further processed by the another process. Memory buffer data which is inserted by one process and further processed, analyzed and calculated by other process. A big problem in embedded systems occurs in embedded software when an interrupt service routine and the main program share the same data. What happens if the main program is in the middle of doing some important calculations using some piece of data…an interrupt occurs that alters that piece of data…and then the main program finishes its calculation? Oops! The calculation performed by the main program might be corrupted because it is based off the wrong/different data value. This is known as the  shared data problem

ESD (SEMAPHORES)

 SEMAPHORES: semaphores belongs to synchronization primitives the other types include: mutex locks, conditional variables,  monitors barriers semaphores helps coordinate between the multiple concurrently running threads or processes. concurrently means that multiple threads are running together to solve a particular issue so they have to share information, memory, data between them.  semaphore is basically a unsigned integer with some quirks one of the quirk is changes to the value of variable is atomic that is if one thread or process increments the value and other wants to decrement the value the increment and decrement operation cannot interrupt each other. We can interact with semaphores with two ways: wait() post() or signal() we cant access the semaphore value directly if you want do anything with semaphores we can either call wait or signal. wait() try to decrement the value of semaphores and post() try to decrement the value of semaphores. wait() try to decrement ...

ESD (TASKS AND STATES)

Image
 Tasks in embedded system a task is a process or thread in an operating system. an application program is also said to be a program consisting of tasks. Task: it is the term used in the RTOS in the embedded system. runs when it is scheduled by the OS. task request or sends or recieves messages through OS functions. task is that executional unit of computation which is controllled by (i) OS process scheduling mechanism--->which executes on CPU. (ii) OS process resource management mechanism that lets it use the system memory, files, network, printer. Task is an independent process. No Task can call another Task. Task can send messages that lets another Task run. The OS can block a running Task and let another task gain the access CPU to run the service code. for example: AUTOMATIC CHOCOLATE VENDING MACHINE Task user keypad input Task read amount chocolate delivery Task Display Task GUI Task Communication task STATES OF A TASK: Idle state(unattached or not registered). Ready state(...
EXTRACT NUMBERS FROM STRING: string = "2 sweets are better than 10 laddus" res=[int(i) for i in string.split() if i.isdigit()] print(res) o/p: [2,10] EXTRACTING NUMBERS FROM LIST OF STRINGS test_list = ['Rs. 24', 'Rs. 18', 'Rs. 8', 'Rs. 21'] print("The original list : " + str(test_list)) res = [int(sub.split('.')[1]) for sub in test_list] print("The list after Extracting numbers : " + str(res)) o/p: [24,18,8,21] EXTRACTING DIGITS FROM STRING teststring="242 is greater than 255" res=[int(i) for i in teststring if i.isdigit()] print(res) o/p: [2,4,2,2,5,5] EXTRACTING WORDS FROM STRING import re teststring="Geeksforgeeks,    is best @# Computer Science Portal.!!!" res=re.findall(r'\w+',teststring) print(res) o/p: ["Geeksforgeeks","is", "best", "Computer", "Science", "Portal"] PROGRAM TO FIND THE DAYS BETWEEN TWO DATES from datetime i...