Tuesday, November 24, 2015

OS : Multithread


Recently, I have one doubt over process.  I tried to understand it, but as it mostly happens to understand it I had to check something else.


https://computing.llnl.gov/tutorials/pthreads/


When we run a program, a PROCESS is created. Now each PROCESS is actually a default THREAD, which requires ONE CORE of CPU.

All this doubts came since now CPU are multiprocessor and multicore.

So when we have octa-core CPU, that means it has 8 cores. Now on this CPU we can run 8 threads at same time.

Now if no PROCESS is creating any threads, then we have 8 PROCESS running at same time on this CPU.

Now each PROCESS has its own ADDRESS SPACE.  But THREADS of same PROCESS share the ADDRESS SPACE of default THREAD of the PROCESS.


But with SINGLE CORE CPU, even when we have multiple THREADED program written, THREADS will be running one after another.

Now if we have put our THREAD into sleep or if it is waiting for some resource, then CPU will process some other THREAD based on PRIORITY.


Also please note, when you are making a multithreaded program, then you divide your FUNCTIONALITY into SUB-FUNCTIONALITY and assigns each SUB_F  to threads.

Each THREAD entry point is call to that FUNCTION.


Use Case :

1) You have to guess a word which is 4 letter and starts with W and ends with R.  Now I will give you one such word with all four letters. You have to see how fast you can reach it.

Now with multi-core CPU, we can use both CORE to work parallely to guess words.

This is when you have MULTICORE processor

2) In case of SINGLE PROCESS which has two parts, one BACKGROUND/DATA PROCESSING and ONE FOREGROUND. In this case we don't want our FOREGROUND process to be slow because of BACKGROUND.

This is use case when you have SINGLE CORE processor.

Make a program in which one THREAD writes data to text file and one THREAD is printing loop count, and one thread is calculating fibonacci series.  See when you perform READ/WRITE operation does fibonacci program runs.



-----------------------------------------------------------------------------------------------------------------------

How does THREADS get scheduled ?

Can we call some THREAD from other task ? We have thread id, but is there any API to call THREAD from the thread id.

Does Modem uses THREAD ? if yes where and why

Friday, November 13, 2015

Algorithms and Data Structures : Index


The way you should go about learning algorithms ( IMO) is like below


Stage 1) Basic Data Structures

These are basic structures and used to store data. Not much operation can be done on these

Linked List
Array
Structures
Matrix ; N-D array

Circular Linked List
Double Linked List
String


Stage 2)  Advanced Data Structures

I have name them advanced, since these uses basic data structures and on top of that one these are built. Also algorithm/ predefined operations are associated with them.

Queue
Stack
Circular Queue
Priority Queue

Tree
Binary Tree
Bianry Search Tree
Huffman Tree
Parent Array
Heap

Set
Adjacency List
Adjacency Matrix

Suffix Tree and LCS array


Stage 3) Algorithms

Boyer Moore Algorithm
KMP Algorithm
Karp Robin Algorithm
String Compression : Brute Force and Huffman Tree
Dijkstra , Bellman-Ford , Floyd-Marshall
Subset, Permutation,Combination Generation - Brute-Force and Backtracking
Sorting Algorithm
Tree Traversal - Pre-order, Post-order, In-order
Graph Traversal - DFS , BFS
Prim , Krushal
String reversal

Stage 4) Solving Methods

Back tracking
Recursion
Iteration
Greedy Approach
How machine stores data
Maths
Time Complexity and Space Complexity
Memorization





Tuesday, November 10, 2015

C language : Index



I am realizing now the importance of Index, when I myself has to check which topics are covered and which not.


1.  Extern
2.  Static
3.  Memory Layout
4.  malloc, free, realloc
5. mulititasking, multithreading,multiprocessing
6. Pointers : function and void
7. File I/O.
8. Storage of unsigned and signed
9. Bits operation

Saturday, November 7, 2015

LTE : Part 1 : Connection with the Network


How does UE remains connected to the Network in LTE


APN : Access Point Name

It identifies the PDN ( the packet data network ) to which UE will communicate .
APN also helps in identifying the type of service. ( default, mms, internet etc).

Check the APN settings of your phone, you will see in APN
 > type
 > IPv4/Ipv6

APN name will be  like  airtel.mnc078.mcc405.gprs


PDN is packet data network , which will provide that type of service ....MMS , internet , IMS

P-GW  is PDN gateway, which is last node of LTE network, it is gateway/server/computer which will provide the service promised by the APN which UE used.


PDN address : It is the IP address which UE has to get identity in the PDN network.


Now since LTE is only PS network, so you should always need connection with the some PDN.
Hence when we attach with LTE network for the first time, we will be activating some APN.

That APN is known as default APN.

Bearer :  It is name given to identify two end points in LTE network.

 EPS bearer : Between  UE and P-GW
 S5/S8 bearer : Between S-GW and P-GW
 E-RAB : Between UE and S-GW
 Radio Bearer : Between UE and eNB
 S1 Bearer : Between eNB and S-GW.


So now in brief, when you bootup

You will try to attach to network, and also try to get the default APN up.
Now when these two things are done , we are connected to network.

but as cellular technologies are mainly for moving devices, we will face problem, when our device has moved to other location.

Hence when we focus on LTE we focus on two parts.  SIGNALLING : this helps in keeping both UE and Network in contact.

Then is DATA part, which helps in moving packets from UE to Network and vice-versa.

We will see first SIGNALLING and then DATA part.


Friday, November 6, 2015

LTE : Part 0



LTE is  technology which provides more data speed then 3G and 2G. Also known as 4G.

Unlike 3G, it is only PS network.


Now any user who has used phone uses it mainly for

CALL, SMS , SS , DATA.

Now CALL is mostly CS. And since we were using LTE and it is only PS , we have IMS which provides CALL facility to user.

Now using IMS we can have SMS, and RCS ( RCS is rich communication service (like whatsapp))


So if you have a IMS module and PS connection ( LTE mobile phone, desktop, laptop) you can connect to the outer world easily.

One more important thing is needed, which is SIM , this is simply needed so that OPERATOR can provide us secure service and offcourse they will earn money.


Now in following post we will try to see  how PS connection is provided using LTE. 

Things we will cover will be

1) APN
2) Security
3) Lower Layer working
4) Connection with Network

Wednesday, November 4, 2015

Tizen : Will i be able to make some App :)


Pheww.....Now I have also started to learn Tizen ..because all the DS and algos I am learning where to put them ...let see if i can get something good from the TIZEN.


It is OS from my own company .....yippy    Happiness ends there only, since I don;t get a chance to work on it.

Now at very basic level Tizen apps are divided into two parts

1) Web App : which can be developed using JavaScript and doesn't needs telephony functionality
2) Native App : which are much stronger and uses C++. These app uses telephony functionality


We will start with basic app, since as I heard it is easier to make.

The most basic app is the one which displays time ...you can find it in tizen SDK when you will start your first project.


Basically for WEB APP,

we have  JS folder in which our javascripts will go
then we have image folder in which all the images which we want to use in our app will be kept
then we have one index.html  in which we can define basic of app.

We will need some basic of html,JS to work.


In next post , we will try to develop some  WEB APP.