Wednesday, 17 February 2016

Importance of static variables in C

In this post I am going to tell you about why you need to declare the local variables of a function as a static?
In the below example there are two functions getBuckets(uint32_t key, struct Table *td) and lookup(uint32_t key, struct Table *td). The lookup() function internally calls the getBuckets() function. The getBuckets() function returns an array of integers, which can be then accessed by the bucketList variable of a lookup() function.
If I did not declare the bucketID variable as a static then soon after the execution of the getBuckets() function the stack will flush out and all the local variables will be reinitialized. So I declared it as a static variable so that the system will allocate memory separately not on the stack. So you can still excess values  of that particular variable out side from that particular function.


Tuesday, 26 January 2016

My first Realtime application



Its fun to work with Appbase.io. Its all about realtimetongue emotico.
Now is my first realtime application. Here is the blog about it and about how to build realtime applications using appbase.


Friday, 15 January 2016

Print error message in Go

Best way to print the error in Go lang.
You need to import runtime and log packages.

Saturday, 26 December 2015

What is GSoC ?

Details about Google Summer Of code(GSoC)

what is GSoC?
Google Summer of Code (GSoC) is a program that matches  mentoring organizations with college and university student developers who are paid to write open source code. Each year, Google works with many open source, free software and technology-related groups to identify and fund proposals for student open source projects.
GSoC pairs accepted student applicants with mentors from participating projects. Accepted students gain exposure to real-world software development and an opportunity for employment in areas related to their academic pursuits. In turn, participating organizations are able to identify and bring in new developers more easily. Best of all, more source code is created and released for the use and benefit of all; all code produced as part of the program is released under an open source license.
This program has brought together thousands of students and mentors from over 100 countries worldwide. At the time of writing, over 200 open source projects, from areas as diverse as operating systems and community services, have participated as mentoring organizations for the program. Successful students have widely reported that their participation in GSoC made them more attractive to potential employers and that the program has helped greatly when embarking on their technical careers. This is the summer internship sponsored  by  Google.

Goals of the Program

The program has several goals:
  • Get more open source code written and released for the benefit of all.
  • Inspire young developers to begin participating in open source development.
  • Help open source projects identify and bring in new developers.
  • Provide students the opportunity to do work related to their academic pursuits during the summer: "flip bits, not burgers."
  • Give students more exposure to real-world software development (for example, distributed development and version control, software licensing issues, and mailing list etiquette).


What is student criteria ?
A student participating in GSoC is typically a college or university student;  the only academic requirement is that the accepted applicants should be enrolled in an accredited academic institution. Students must also be at least 18 years of age in order to participate. Students come from a variety of academic backgrounds, and though most students are enrolled in a Computer Science program there is no requirement that they be studying CS; past student participants in GSoC have come from disciplines as varied as Ecology, Medicine, and Music.
Students submit project proposals to the various organizations participating in GSoC. The organizations select which student proposals they would like to see funded by Google.

Selecting a Student

There are some student qualifications that are important for any successful GSoC experience. The student needs to be highly technically skilled, needs to have good communication skills, and needs to be a hard worker with sufficient available time to succeed. The entire selection procedure take place on this platform- https://www.google-melange.com/gsoc/homepage/google/gsoc2016
They select students on the basis of their contribution,interview performance & the proposal detailed about project’s implementation.


Types of Synchronizations

To avoid the race conditions in Parallel Programming there are two types of synchronizations between threads (Process).
1). High Level Synchronizations.
2).  Low Level Synchronizations.

  These kind of methods are useful for the shared memory computers.

Difference between High and Low Level Synchronizations

  Low level synchronizations affects one thread only where high level synchronizations affects many threads.

1. High Level Synchronizations Types

- Critical
  What critical does is mutually exclusion. The idea is to create one critical section, and this section can only executes one thread at a time. If one thread already code of that section then thread will wait until it completes the execution.

Atomic Access
  In programming, an atomic action is one that effectively happens all at once. An atomic action cannot stop in the middle: it either happens completely, or it doesn't happen at all. No side effects of an atomic action are visible until the action is complete. The atomic access is need for the general binary operations like a++, because it  does not describe an atomic action. Declaring an block of code atomic guarantees that operations made on the variables occur in an atomic fashion, i.e., that all of the substeps of the operation are completed within the thread they are executed and are not interrupted by other threads.

Barrier
  Barrier is the point in program at which threads stop and wait. When all the threads have reached the barrier, they can proceed. Synchronization barriers are useful for phased computations, in which threads executing the same code in parallel must all complete one phase before moving on to the next. Example - Suppose you have a null array of size 100. Your system can make only two threads to write data and to shift the data on the left side. So first of all you divide the array between two threads to write the data and then put the barrier on it to complete the phase of read data. After that if both the thread reach at the same barrier point then only able to shift the data.

Ordered
  Every execution has a synchronization order. A synchronization order is a total order over all of the synchronization actions of an execution. For each thread t, the synchronization order of the synchronization actions in t is consistent with the program order of t.

2. Low Level Synchronizations

- Flush
  Used to make a thread's view of shared data consistent with main memory. Shared data are stored in main memory locations that are supposed to be accessible by all threads. The modified data has to be stored in main memory before the flush can complete, and unchanged data has to be read again from the main memory after the flush is complete. Flush allows us to keep memory consistent in a cross platform way.

- Locks



Sunday, 1 November 2015

FreeBSD Setup

How to install FreeBSD on your Mac OS (Yosemite) ? 


  Today I am writing this blog post about how to install FreeBSD OS on your Mac machine. Let me first introduce about FreeBSD organization.

  FreeBSD is an advanced operating system for modern server, desktop, and embedded computer platforms. FreeBSD provides advanced networking, impressive security features, and world class performance and is used by some of the world's busiest web sites and most pervasive embedded networking and storage devices.

So Ready To install it ??

  Here is the page about how to set up your developer environment.

  If you wanted to install it on remote machine (AWS) and then wanted to use it then go with the second option mentioned in the above url.  This environment however requires you to be online each time you want to do something.

Let me talk about how did I install FreeBSD os on my local machine :
  I used Virtualbox to run FreeBSD along with the Mac OS. First of all I created separate virtual machine with BSD 64-bit os, certain amount of RAM and virtual hard disk. After that I selected .iso as the "content" of my virtual CDROM drive and made it bootable. So now Virtualbox able to boot the FreeBSD os from the CDROM drive and I am able to use it :).
  A FreeBSD installation will require a minimum 64 MB of RAM and 1.5 GB of free hard drive space for the most minimal installation. However, that is a minimal install, leaving almost no free space. RAM requirements depend on usage. Specialized FreeBSD systems can run in as little as 128MB RAM while desktop systems should have at least 4 GB of RAM.


Install VirtualBox

  Virtualbox gives ability to install and run multiple Operating Systems on your desktop or laptop computer in virtual environment without disturbing the host OS. You can have Windows XP, Linux OS and even Windows 95 on your latest Windows 7 laptop. In this case, your laptop will be the ‘host’ and virtual machines will be the ‘Guest’s. You can download it from here - https://www.virtualbox.org/

Choose Image

 The FreeBSD installer can be downloaded in a number of different formats including CD (disc1), DVD (dvd1), and Network Install (bootonly) sized ISO Disc Images, as well as regular and mini USB memory stick images. Later versions of FreeBSD are also offered as prebuilt expandable Virtual Machine images, and as SD Cards for embedded platforms.
  There are already FreeBSD images available to run it on virtual environment. You just need to choose an image according to your machine architecture and run it using virtual environment. Computers with more than 3 GB of memory should use amd64 image. If the computer is an older, 32-bit only model, use i386 image. My machine has 4 GB memory and 2.5 GHz Intel Core i5 64-bit system. So amd64 would be the best image for me.

Install Image

  To boot os from the CDROM I need the installer image. I am using FreeBSD 10.2 release bootonly i so image (amd64) for the bootable CDROM drive. It boots a small image from the CD/DVD that then gets the rest of the installation from an online repository.
Link to amd64 installer images - ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/10.2/


Image showing selected iso file.

  Now whenever I run this machine it will automatically boot my virtual PC from the CDROM and I am able to install the system. It uses Copy-On-Write disks by default, so it won't waste too much space on my disk.




Image of running FreeBSD os

Saturday, 10 October 2015

GSoC Proposal 2015

GSOC-Idea Create new interactives for Investigations      curriculum units

Personal Information

  • Name - Rishi Shah
  • Age - 18
  • Address - Ahmedabad, Gujarat-380013, India.
  • Phone number(s) - +91-9824513046
  • E-mail address- rishiloyola98245@gmail.com

Education

   I am an ICT (Information and Communication Technology) undergraduate student at Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT),Gandhinagar, India which is a hotbed for open source developers in my country. I am currently in my first year, slated to get my degree in 2018. I am an active member of the Google Developer Group chapter of DA-IICT.


Courses I have completed -
  • Introduction to C Programming
  • Object Oriented Programming using Java
  • Data Structures and Algorithms


  These courses laid the foundations of my programming skills which made it easy for me to learn , use and contribute to open source.
  I went to school ST.Xavier’s Loyola, which is the one of the top 10 schools in my state. I completed my higher senior secondary in 2014. I belong to science stream. I am very passionate about programming and coding. During my first sem of college I jumped into the coding and development world. I made a snake game using HTML & javascript, and made a solid state web-app. My inspiration for this app drew from the problems I faced visualizing 3D geometry in my schooling. I have good knowledge of physics, chemistry, and maths. I am very creative and enjoy painting and designing.


Work and Open-Source Experience

Startup Experience
Employer Name - Rygbee(Social network)
Job - Web developer,
       -My job is to design front end part using AngularJS and I have to make linkage between   
        servlet and JADE gateway through Spring framework .                                 
Date - 5th January to April 2015


Open Source Experience
Organization Name - Sugar Labs
Project - Sugar Labs Developer
              Made Web App based on HTML5,Javascript & CSS
Date - December 2014 onwards


Organization Name - Code Combat
worked - Solved & issued bugs related to Javascript, coffeescript and CSS
Date - December 2014 onwards


Organization Name - The Concord Consortium
worked - Improved few lab-interactives
Date - December 2014 Onwards

Programming Experience

  • Proficient in Javascript,C,HTML
           Used HTML & Javascript to build web-apps.
  • Significant experience with Java,CSS,PHP
           Used PHP & CSS to make landing page for Rygbee.
  • Frameworks - AngularJs,Jquery,Spring
           Used Jquery to make Solid state web application and used AngularJs to make web page
  • Database - OrientDB

Operating System Experience

  • Linux(Fedora & Ubuntu 14.04 LTS)  
  • Windows

Which Project(s) Do You Want to Work On?

Priority Wise :
1.Create new interactives for Investigations curriculum units
2. Move popular materials from Java to HTML5
3. Control of simulations with gesture input


How Will You Successfully Complete Your Project?

   For this project my job is to develop new interactives which can be fit into curriculums units.It is very essential and important project because users directly get into touch with it. so it all depends on how I am developing it interactive and user friendly by just adding few features related to interactive. To add more features I need to edit lab framework, lab grapher, lab interactives.
 I know the basic code flow of lab grapher and lab interactives and I’m trying to understand code flow of lab framework. Even when I understand it, I research a lot and do not hesitate to take help of my mentor, of course after web surfing.
 In my previous experience with the concord consortium, to understand basic work flow, I played with the code locally until I got a grip of the project I was working with. Before my internship starts I would like to understand the whole working of the system from starting to end so that I can work on the code with full swing and without any hesitation.
  My mentor is at GMT - 5:00 and I am at GMT: +5:30 so to work together I will contact to my mentor during his active time.

Motivation

     Many people advised me to go for KDE or such organizations so that I have a better prospect. But it isn’t just about getting selected.
     First, the idea itself intrigues me a lot. During my primary education I faced many problems to understand concepts of science by visualization. We didn’t have sufficient experimental apparatus or any kind of software to experiment or understand it.Through this project I want to make new interactives so that others will not face the same problem that I faced during my school time.We can make science more interesting through these models.
   Today the world is changing continuously. With the help of new technologies, computational science, & softwares we can build models to understand,to test, and to play with science. I think The Concord Consortium approaches the problem of unavailability of labs component in a nicer way.
  Additionally I like how The Concord Consortium offers a very welcoming environment to new contributors even if they don't have any experience with open-source projects.I would love to push The Concord Consortium forward to become more popular, either through Google Summer of Code contributions or just through contributions in my leisure time.

How you find out about us?
I am very passionate about creating innovative scientific models, which makes science easy to understand. My hobby is to make new applications based on simulations which enable users to interactively visualize and analyze the dynamics of scientific concepts. So to develop such kind of activities I need some good enough platform which provides me an initial kind of push up. Of course such kind of help and encouragement are generally provided by open source organizations.  So after surfing on net on these kind of platforms, I came to know about The Concord Consortium. I instantly started liking it and started contributing to it.


Code

                        Using  HTML5,Javascript,CSS,Canvas


                                         Using  HTML5,Javascript,Jquery,CSS,Canvas


Contribution in The Concord Consortium
  • Radio Activity Model
  • Breaking Molecular Bond
 
    Submitted Patches
  • Breaking molecular bond table version
  • Making breaking bond:dissociation energy
  • Lab-grapher : To hide axis values

Schedule

  I have my final exams from 27th April to 2nd May 2015. I don't have any other obligation other than my GSOC Project  and intend to devote more than 40 hours a week for this project. My college vacations are from early May to late July. Also just after college reopens, there would not be any load due to college curriculum, so I will be able to devote my maximum time towards my project. I am even ready to work at the weekends if the project demands so.


Eligibility

Yes, I am eligible to receive payments from Google.