Enable contrast version

Tutor profile: Atul A.

Inactive
Atul A.
5+ years computer science/programming tutor. Professional software developer.
Tutor Satisfaction Guarantee

Questions

Subject: Javascript Programming

TutorMe
Question:

What is a "closure" in JavaScript?

Inactive
Atul A.
Answer:

A closure is an inner function that has access to the variables in the outer (enclosing) function's scope chain. The closure has access to variables in three scopes; specifically: (1) variable in its own scope, (2) variables in the enclosing function's scope, and (3) global variables. Here is an example: var globalVar = "xyz"; (function outerFunc(outerArg) { var outerVar = "a"; (function innerFunc(innerArg) { var innerVar = "b"; console.log( "outerArg = " + outerArg + "\n" + "innerArg = " + innerArg + "\n" + "outerVar = " + outerVar + "\n" + "innerVar = " + innerVar + "\n" + "globalVar = " + globalVar); })(456); })(123); In the example above, variables from innerFunc, outerFunc, and the global namespace are all in scope in the innerFunc. The above code will therefore produce the following output: outerArg = 123 innerArg = 456 outerVar = a innerVar = b globalVar = xyz

Subject: Computer Science (General)

TutorMe
Question:

With regards to concurrency, what is a spin-lock?

Inactive
Atul A.
Answer:

A spin-lock is a lock which causes a thread trying to acquire it to simply wait in a loop (spinning state) while repeatedly checking if the lock is available. Since the thread remains active but is not performing a useful task, the use of such a lock is kind of busy waiting. It's usually used when there is a low contention for the resource, so the CPU will therefore only make a few iterations before it can move on to some productive work. The regular lock is used if the resource cannot be acquired in a reasonable time-frame. This is done to reduce the overhead with context switches in settings where locks usually are quickly obtained. while (try_acquire_resource()); ... release(); It performs a very lightweight locking/unlocking but if the locking thread will be preempted by other which will try to access the same resource, the second one will simply try to acquire the resource until it runs out of CPU quanta.

Subject: C Programming

TutorMe
Question:

What is indirection in C?

Inactive
Atul A.
Answer:

If you have defined a pointer to a variable or any memory object, there is no direct reference to the value of the variable. This is called the indirect reference. But when we declare a variable, it has a direct reference to the value.

Contact tutor

Send a message explaining your
needs and Atul will reply soon.
Contact Atul

Request lesson

Ready now? Request a lesson.
Start Lesson

FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.
BEST IN CLASS SINCE 2015
TutorMe homepage
Made in California by Zovio
© 2020 TutorMe, LLC
High Contrast Mode
On
Off