01:198:214 Lecture Notes - Lecture 9: Compile Time, Semaphore (Programming)
//-------Notes for November 2nd-------\\
//-------Const-------\\
const int x = 2;
x=3;
^
creates and error during compile time.
Valic
const int x = 2;
int y = x;
we arent changing x so it is ok const makes it read only
Constants goes in text or data depending on the compiler
1 - const char* ptr = ...
2 - char* const ptr = ...
3 - const char* const ptr = ...
which one does this lock down?
*ptr = "" - Locks down the data for 1
ptr = some address - Locks down the address for 2
Locks both data and address
Works :
const int x = 3;
int * y = &x;
*y = 4
^
is valid
int x = 3;
int const * y = &x;
Locks down the value
//-------Static-------\\
Static: All instances see he same var in all scopes before, during and after
your code
Semaphore :
Asychronous : Insensitive to ordering of calls
Threadsafe : Insensitive to identity
why is this good for signal handlers?
Signal handlers can run in any context at an time (Between any
instructions)
[Do not want to use for Insensitive to identity stuff or Insensitive to
ordering stuff]
Semaphores -
--------------------------------------------------------------------------------
---------------
//-------Sockets-------\\
Sockets
open(path,options)
path is a target to something local so if it is isnt local we need its address
socket(int domain, int socket, int protocol) creates an endpoint for
communication and restursn a descriptor
mostly INET Ipv 4 - How our network Works
Type of Socket:
we msotly care about Sock_Stream transmition protocol
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
//-------const-------\ const int x = 2; x=3; creates and error during compile time. Valic const int x = 2; int y = x; we arent changing x so it is ok const makes it read only. Constants goes in text or data depending on the compiler. *ptr = - locks down the data for 1 ptr = some address - locks down the address for 2. Works : const int x = 3; int * y = &x; *y = 4 is valid int x = 3; int const * y = &x; Static: all instances see he same var in all scopes before, during and after your code. Signal handlers can run in any context at an time (between any instructions) ordering stuff] [do not want to use for insensitive to identity stuff or insensitive to.