What is process? Describe the states of a process.


A process is a program in execution. A process is more than the program code, which is sometimes known as the text section. It also includes the current activity, as represented by the value of the program counter and the contents of the processor’s registers. A process generally also includes the process stack, which contains temporary data (such as function parameters, return addresses, and local variables), and a data section, which contains global variables. A process may also include a heap, which is memory that is dynamically allocated during process run time. The structure of a process in memory is shown in Figure 3.1

Process State:

As a process executes, it changes state. The state of a process is defined in part by the current activity of that process. A process may be in one of the following states:

New: The process is being created.

Running: Instructions are being executed.

Waiting: The process is waiting for some event to occur (such as an I/O completion or reception of a signal).

Ready: The process is waiting to be assigned to a processor.

Terminated:The process has finished execution.

These names are arbitrary, and they vary across operating systems. The states that they represent are found on all systems, however. Certain operating systems also more finely delineate process states. It is important to realize that only one process can be running on any processor at any instant. Many processes may be ready and waiting, however.

Ref: Operating system concepts by silberschats , 9ED

Essential libraries for every android projects

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'

Android call activity methods from fragment , fragment method from activity and fragment method from fragment in kotlin in Android

1. Call activity method from fragment :

(activity as ActivityName).methodName()
(activity as MainActivity).userInfo()

2. Call fragment method from activity

  var fragment = supportFragmentManager.findFragmentById(R.id.content) 
  as UserInfoDetailsFragment

3. Call fragment method from fragment


Android recycler view item click listener from Activity or Fragment

First Create an interface . NotfallKontakteEntity is Model of list items

public interface OnItemClickListener {
    void onItemClick(NotfallKontakteEntity item);

Then in adapter define and create constructor with click listener

public  OnItemClickListener listener;

public NotfallKontakteAdapter(List<NotfallKontakteEntity> notfallKontakteEntityList, OnItemClickListener listener) {
this.notfallKontakteEntityList = notfallKontakteEntityList;
this.listener = listener;

Now just declare it any click item view OnClickListener . Must add the item position as parameter.

  userHolder.delete.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v)

Now time to user this click listener. We can use anywhere in our fragment or activity

     recyclerView.setAdapter(NotfallKontakteAdapter(contactList, object : OnItemClickListener {
            override fun onItemClick(item: NotfallKontakteEntity) {
               Toast.makeText(context, contactList.id.toString(), Toast.LENGTH_LONG).show()


Android toggle visible password field easy way

Just paste these code for password edittext field

            app:layout_constraintTop_toBottomOf="@+id/txt_Email" >


Reverse a number in c++

#include <iostream>

using namespace std;

int main()
    int originalNumber, reverseNumber = 0 , reminder = 0 ;
    cout<<"Enter a number ";
    std::cin >> originalNumber;
    while(originalNumber != 0){
        reminder = originalNumber % 10;
        reverseNumber = reverseNumber*10 + reminder;
        originalNumber = originalNumber/10;
    cout<< reverseNumber;

    return 0;

Reverse a String in c++

#include <iostream>

using namespace std;

int main()
    string reverseString = "reverse";
    int lengthOfString = reverseString.length();
    for (int i = 0; i < lengthOfString/2; i++) {
        /* code */
        swap(reverseString[i] , reverseString[lengthOfString - i -1 ]);
    std::cout << reverseString;

    return 0;

IOS take Screenshot of full page and share in swift 4

1. Crate a swift file and paste these two as extension

import UIKit

extension UIApplication {

    var screenShot: UIImage?  {
        return keyWindow?.layer.screenShot

extension CALayer {

    var screenShot: UIImage?  {
        let scale = UIScreen.main.scale
        UIGraphicsBeginImageContextWithOptions(frame.size, false, scale)
        if let context = UIGraphicsGetCurrentContext() {
            render(in: context)
            let screenshot = UIGraphicsGetImageFromCurrentImageContext()
            return screenshot
        return nil

2 . How to use :

We can use as UIApplication.shared.screenShot . If we want to set screenshot at a imageview then –

imageView.image = UIApplication.shared.screenShot

3 .Share screenshot

 let imageToShare = [UIApplication.shared.screenShot]
                    let activityViewController = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
                    activityViewController.popoverPresentationController?.sourceView = self.view
                    activityViewController.excludedActivityTypes = [ UIActivity.ActivityType.airDrop, UIActivity.ActivityType.postToFacebook ]
                    self.present(activityViewController, animated: true, completion: nil)

IOS UI Search bar with keyboard actions in swift 4

1 .Fist Create a ViewController and extends UISearchbarDelegate

SearchViewController: UIViewController, UISearchBarDelegate{}

2 . Register search bar as like in ViewDidLoad

self.searchBar.delegate = self

3. Now call keyboard search action func

 func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {

4 . Cancel button function

 func searchBarCancelButtonClicked(_ searchBar: UISearchBar){

Complete Code

import UIKit

class SearchViewController: UIViewController ,UISearchBarDelegate{

    lazy var searchBar = UISearchBar(frame: CGRect.zero)

   override func viewDidLoad() {

        searchBar.placeholder = "Search"
        navigationItem.titleView = searchBar
        searchBar.text = "this"
        self.searchBar.delegate = self
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1

    func searchBarCancelButtonClicked(_ searchBar: UISearchBar){
    func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {

Working with Augmented reality – ARCore

What is ARCore

ARCore is Google’s platform for building augmented reality experiences. Using different APIs, ARCore enables your phone to sense its environment, understand the world and interact with information. Some of the APIs are available across Android and iOS to enable shared AR experiences.


ARCore uses three key capabilities to integrate virtual content with the real world as seen through your phone’s camera:

  • Motion tracking allows the phone to understand and track its position relative to the world.
  • Environmental understanding allows the phone to detect the size and location of all type of surfaces: horizontal, vertical and angled surfaces like the ground, a coffee table or walls.
  • Light estimation allows the phone to estimate the environment’s current lighting conditions.

Supported Devices

ARCore is designed to work on a wide variety of qualified Android phones running Android 7.0 (Nougat) and later. A full list of all supported devices is available here.

Working With ARCore For Android

Create an Android project and paste these code to the gradle(app) file

Create an Android project and paste these code to the gradle(app) file

implementation ‘com.google.ar.sceneform.ux:sceneform-ux:1.6.0’
implementation ‘com.google.ar.sceneform:core:1.6.0’
implementation ‘com.google.ar.sceneform:assets:1.6.0’